Arduino First to 20 Game!




Introduction: Arduino First to 20 Game!

About: I am an aspiring engineer currently enrolled in Mechatronics Engineering and Management at McMaster University.

This application uses the Arduino board to play the classic first to 20 game. Here's how the game works. You as the user will compete with the computer to reach the number 20 first by only adding either 1 or 2 to the score every turn. The first to 20 wins the game.

Step 1: Parts

These are the parts you will need:

1) Arduino Board (I went with the Arduino UNO)

2) 2 Potentiometers

3) LCD (I used a 16x2 LCD)

4) Wires

Step 2: Wiring the LCD

I followed the circuit diagram provided above to wire up the LCD. I highly recommend soldering the wires to the LCD to ensure maximum reliable performance. However you can also loop wires tightly around their corresponding pin hole. The latter method runs the risk of wires contacting each other with might affect the LCD performance. I also recommend using the breadboard for wiring.

The various pin wiring:

  1. VSS pin to ground and leftmost pin of potentiometer.
  2. VDD pin to 5 V and rightmost pin of potentiometer.
  3. V0 pin to centre pin for potentiometer.
  4. RS pin to digital pin 12.
  5. RW pin to ground.
  6. E pin to digital pin 11.
  7. The next 7 pins are data pins and only 4 of them have to be used. I went with D4 to D7, wiring them to digital pins 5-2 respectively.
  8. Pin A to 5 V.
  9. Pin K to ground.

Although the last 2 pins are not wired in the diagram, I went ahead and wired them up as they provide the back light for the LCD. The use of the potentiometer in this case is to adjust the contrast of the LCD.

Step 3: Wiring the Control Pontentiometer

The input of the addition of 1 or 2 is done through the use of a pontentiometer. The way I did this is by finding the max and min value of the potentiometer. The max value was about 1024 and min value was 0. So I decided that an input of less than 512 (mid point of min and max) would be considered input of 1 and greater than 512 would be considered input of 2.

Wiring the Potentiometer:

  1. Leftmost pin to ground.
  2. Centre pin to analog pin A0.
  3. Rightmost pin to 5 V.

Step 4: Program

This is the code needed to run this application. I do believe it can be shortened as I have not played around with Arduino in a while but nonetheless it is here for your viewing.

Be the First to Share


    • Raspberry Pi Contest

      Raspberry Pi Contest
    • Anything Goes Contest 2021

      Anything Goes Contest 2021
    • One Board Contest

      One Board Contest



    4 years ago

    Nice little project for beginners but why do you use a pot? Wouldn't two push buttons be simpler and better?


    Reply 4 years ago

    two pots*


    Reply 4 years ago

    Yeah you're right but I had no push buttons on hand. So I just worked with what I had. If you do have push buttons then those should work great with this game.

    DIY Hacks and How Tos

    This project would be great for teaching the basics of microcontrollers. When you make it a game people are much more motivated to learn.


    Reply 4 years ago

    Thanks and I agree! :)