Introduction: Arduino Dice Tower Game
In this instructable i'm gonna show you how to build a dice tower game with arduino, five servo's and some sensors.
The goal of the game is simple, two people throw a dice in the top and you take turns pressing a button, or otherwise manipulating the sensors. When you do the servo move the platforms on both sides of the box making the dice drop down. The first to get his dice out of the towers wins with the bonus of seeing what he/she rolled.
This project can easily be modified or expanded to use other fun sensors or be bigger or smaller.
Step 1: Requirements
For this project you will need:
- An AC/DC Adapter (5V, 2.1A, Centre Positive)
- An Arduino Uno
- An USB-B cable
- 32x male jumper wire
- 5x servo
- 5x 10k resistors
- 3x Push Button
- A Force Sensitive Resistor
- A Light Sensor
- MDF plate or other wood
- wood glue
- wood skewers
- sheet of plastic
IMPORTANT: The adapter has to be 5 volt because this is the voltage of the servos and more might break them. Also check the adapter is centre positive and has more than or 2A to power all the servos.
Step 2: Power
For all the servos to work you're going to need a lot more power than the arduino can supply. This is what the adapter is for. The adapter is 5V which is the operating voltage of the servos as well as all the sensors so that will be perfect. Furthermore it supplies 2.1A which is enough for all the servos at once. So first of all your going to cut the wire of your adapter and skin it. If you have to seperate wires one of them is the 5V and the other one is the ground. If you have one thick wire that means both wires are in there and you'll have to seperate them. You can use a multimeter to see which wire is the 5V. If you put your probes on the wires and it reads 5V the wire on the red probe is 5V and the one on the black probe is ground. if it reads -5 volt it means you have them the wrong way around. Now you can wrap a wire around both and put them into your breadboard, the 5v in the + and the ground into the -. Now there is one last thing to wich is run a wire from your arduino's ground to the - as well so that the adapter and the arduino have a common ground otherwise it won't work.
Step 3: Servos
Next we're going to wire up our servos. Now each servo has three wires a yellow one, an orange one and a brown one.
- Yellow to (PWM) pin 4, 5, 6, 9, 10, 11
- Orange to power
- Brown to ground
But you can't just connect them to any pin, it's important to use the PWM pins. While most digital pins can only be on or off the PWM pins can also send values in between which we need to put the servo in any position we want.
Step 4: Push Buttons
Next we are going to wire up the three push buttons to control servos 1, 2 and 4.
- Connect push button to breadboard
- From right button leg to power.
- From left button leg to pin 3
- From left button leg to 10k resistor
- From 10k resistor to ground
Now repeat this for all three buttons.
Step 5: Force Sensitive Resistor
Up next is the force sensitive resistor which measures force. Now for this sensor we are going to be using the analog pins because the analog pins work with values between 0 and 1023 instead of just on or off which is necessary for the force sensor.
- Connect the force sensitive resistor to the board
- Left pin to power
- Right pin to analog pin A0
- Right pin to 10k resistor
- 10k resistor to ground
Step 6: Light Sensor
And finally we are adding the light sensor. Make sure the long pin is on the left.
- Connect the light sensor to the breadboard
- Left leg to power
- Right leg to analog pin A1
- Right leg to 10k resistor
- 10k resistor to ground
Step 7: Casing
Based on the template on the first picture you can saw the planks. Then make the holes indicated on the front and back. Then you can glue everything together to be like pictures 2 and 3. Just don't glue the servo platforms to the servos just use the standard servo parts and screw them to that. Then glue the skewers on and stick them throught the hole. Then on the other side put the other identical platform so that you have two platforms on one servo. So see this refer to the fourth and fifth picture.
Of course you can vary the size of the box as well as the slides on the inside quite easily.
Step 8: Code
This is the code for controlling all five servos using the sensors.
button1 = servo1
button2 = servo2
light sensor = servo3
button3 = servo4
force sensitive resistor = servo5