Introduction: 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.

Step 1: Gathering Your Materials

The materials you will need are the following:

  1. Arduino Uno (other Arduino boards may work but I have never tested any)
  2. Large Breadboard
  3. Small Breadboard
  4. Male - Male Jumper Wires
  5. 3 Push Buttons
  6. 3 resistors
  7. Access to a computer
  8. Some ready to work hands!

Step 2: 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.

Step 3: 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!

Step 4: 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:

Step 5: 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.

Arduino Contest 2019

Participated in the
Arduino Contest 2019