Balance Box Game - Arduino Powered

by g199 in Circuits > Arduino

3544 Views, 17 Favorites, 0 Comments

Balance Box Game - Arduino Powered

20190909_124046.jpg

The balance box game was made for a challenge event, it has to be carried level through an obstacle course or over a set distance in order to win the challenge.

An arduino is used to measure the angle of the box and trigger an alarm once the set angle is exceeded.

The box needs to be moved carefully while being carried level. As the box moves out of level , the balance indicator lights will illuminate, more lights indicates that the box is further out of level. The spirit level can also be used to see if the box is level. When the box is too far out of level or it is bashed, the box will chirp 3 times and play a honk noise, one of the life lights will go off. When all 3 lives have been used the box will alarm and flash all of the lights, the game is lost.

Supplies

Required parts are:

1x Arduino Nano

1x MPU6050 module

3x White LEDs

5x Coloured LEDs for the balance indicator (2 green, 2 yellow, 1 red)

1x Piezo Buzzer

1x TIP120 Transistor

1x 2.2K Ohm resistor

8x 220 Ohm resistor

1x Push Button

1x Power switch

1x "Bullseye" spirit level

5v Power source, my project uses a li-ion 18650 shield with a regulated 5v output

1x Project box

You will need a breadboard and jump wires for testing the circuit

Tools required are:

Drill and bits

Soldering iron

Hot glue gun

masking tape, pencil and ruler for marking out the box

File

The Wiring Circuit

Balance Box.png

The only thing that is not shown on the wiring diagram is the main power switch, in my project this switch is placed between the lithium battery and the shield so that they can be completely disconnected.

If you are not familiar with following wiring diagrams then just take it piece by piece, follow each wire connection carefully and work methodically so that you dont miss anything.

You should assemble the circuit on a breadboard to check that it is working correctly before you solder all of the parts together.

The Life LEDs on the diagram should be the white LEDs

The balance LEDs should be arranged:

Red - Balance LED 5

Yellow - Balance LED 4

Yellow - Balance LED 3

Green - Balance LED 2

Green - Balance LED 1

Arduino Code

Arduno Snap.png

For the arduino code you will need to add some libraries to the arduino IDE, I have included the links below

The additional arduino libraries required are:

MPU6050_tockn.h

OneButton.h

You will need to add the libraries linked above to your arduino IDE

Download and open the file containing the code "Balance_alarm_V1.8.ino"

Upload the code to the arduino board

Fit the Box

20190930_125534.jpg
20190907_205519.jpg
Balance box lid.png

Unfortunately I did not take photographs of the box while i was fitting the components to it. I have used hot glue to fit the parts into the box.

If you are using a plastic box like the one I used, then wrap the top in masking tape and use a ruler and a pen to mark out where you need to drill the holes for the LEDs, the speaker and the spirit level mounting screws.

The switch was fitted by drilling a hole and then filing it out to the correct size and shape.

If I were re-making this project, I would mount all of the components in the lid so I would not have to run as many link wires between the lid and the bottom of the box.

Operating Instructions

20190909_124051.jpg

Starting

Before turning the box on, put the box down on a flat and level surface so that the bubble in the spirit level is in the centre circle.

Turn the power switch on, the box will beep once and boot up. Leave the box stationary until you hear a triple beep and the 3 white “Life lights” turn on.

The game is now ready.

Box functions

The box needs to be moved carefully while being carried level. As the box moves out of level , the balance indicator lights will illuminate, more lights indicates that the box is further out of level.

The spirit level can also be used to see if the box is level (If the spirit level and balance lights do not match carry out a balance sensor reset, see below)

When the box is too far out of level or it is bashed, the box will chirp 3 times and play a honk noise, one of the life lights will go off.

When all 3 lives have been used the box will alarm and flash all of the lights, the game is lost.

Controls

Reset Alarm

Do this to stop the game over alarm after all 3 lives have been lost.

While the alarm is sounding, press the green button for one second and release. The alarm should stop after a second. If not try again

Reset Lives - Do this if you want to reset the game, all three lives will be returned.

At any time, double click the green button (like a computer mouse, but slightly slower). The reset noise will sound and three life lights will be illuminated.

Reset the balance sensor - Do this if the bubble in the spirit level does not match the balance indicator lights.

Long press the green button (press for 3 seconds and release) The balance reset noise will play and the balance lights will flash on briefly and then should go off (indicating that the box is level). It should be done while the box is level as indicated by the spirit level bubble.

Notes

When the box starts to chirp because a life is lost, be quick getting it back to the correct flat position or you will lose another life as soon as the chirping stops, approximately 5 seconds.

Use the spirit level to see which way out of flat/level you are, the lights indicate that you are out of level but they do not show which way.

The bubble of the spirit level is roughly the same as the indicator lights, when the bubble touches the side of the spirit level a life will be lost.

If the box is behaving strangely and a balance sensor reset does not work, turn the box off and on again with the black power switch. You will have to wait approximately 10 seconds with the box on a flat surface while it powers back up. Try to use the balance sensor reset first as it is faster, you do not need to wait for the box to carry out its power up cycle.

The box is battery powered, it should in theory have enough charge to last a full day of constant use, please turn it off if it is not in use to save batter power.

If the button is not responding, please be sure you are pressing AND releasing the button.