Arduino Lock Game
This little lock game will randomize a number and allow you to guess it! The game is controlled by 3 buttons and the number is always 1-9. Please comment any recommendations or issues and I will try to resolve them.
Gathering Your Materials
The materials you will need are the following:
- Arduino Uno (other Arduino boards may work but I have never tested any)
- Large Breadboard
- Small Breadboard
- Male - Male Jumper Wires
- 3 Push Buttons
- 3 resistors
- Access to a computer
- Some ready to work hands!
Setting Up the Bread Boards
To set up the large board do the following:
Set the LCD 1602 display in the bottom right hand of the breadboard like so. Proceed to place the potentiometer across the middle making sure the two pins are on the bottom and the singular one above.
To set up the smaller board as a controller do the following:
Place your three push buttons across the middle gap. Spread them out as much as you want, however make sure the buttons are not connected horizontally but they are vertically (without the button pressed). If you want to test which side are always connected I suggest setting up a simple circuit with an led connected to the button.
Connecting the Wires
Starting with the larger breadboard connect the following:
- 3.3 volts to positive rail
- Ground to negative rail
Then to connect the potentiometer connect the following:
- The upper pin to V0 on the LCD
- The bottom left pin to negative power rail
- The bottom right pin positive power rail
Connecting the display:
- VSS to the negative rail
- VDD to the positive rail
- V0 is already connected
- RS to digital pin 12
- RW to negative rail
- E to digital pin 11
- D4 to digital pin 5
- D5 to digital pin 4
- D6 to digital pin 3
- D7 to digital pin 2
- A to 5 volts
- K to ground
Now onto the controller!
- Connect the bottom left pin of each button with a resistor to the negative power rail (on the other board).
- Connect the bottom right pin of each button to the positive rail (on the other board).
- Then connect the top left of one button to digital pin 7
- Connect the top left of the next button to digital pin 8
- Connect the top left of the final button to digital pin 9
Now everything is all wired up!
Programming
You could program this your self or you could use my code (I am an amateur so it's not the best). If your new to this plug your Arduino in with the USB and upload the code through Arduino's web editor. Here it is:
https://create.arduino.cc/editor/TCD_95/f285ffc9-e5c0-4a63-bce9-a2fd2aac850a/preview
Testing the Game
When you turn the screen on make sure to turn the potentiometer to allow the text to show up clearly. Start by testing if each button works correctly and gives and output. Note that holding the enter button may mess it up so only hold it for a quick second. If you want to play the game again press the red reset button on your Arduino. Now if it all works try to adjust some of the mechanics in the game or add more buttons.