Rock Paper Scissors Game Using Arduino Nano and OLED
by DESHBOT in Circuits > Arduino
27 Views, 0 Favorites, 0 Comments
Rock Paper Scissors Game Using Arduino Nano and OLED
The objective of this project is to create a simple Rock Paper Scissors game using an Arduino Nano, an OLED display, and two push buttons.
The player can select Rock, Paper, or Scissors using one button and press another button to play against the computer.
Supplies
Arduino Nano
0.96-inch OLED Display (128×64, I2C)
2 × Push Buttons
Jumper Wires
DESHBOT Shield
USB Cable
Pin Connections
ComponentArduino Nano
OLED SDA - A4
OLED SCL - A5
OLED VCC - 5V
OLED GND - GND
Change Button - D10
Play Button - D12
The buttons use the Arduino's internal pull-up resistors, so an external resistor is not required.
Working Principle
The game has three choices:
- 0 = Rock
- 1 = Paper
- 2 = Scissors
Change Button — D10
When the D10 button is pressed, the player's choice changes:
ROCK → PAPER → SCISSORS → ROCK
The OLED displays the current selection.
Play Button — D12
When the D12 button is pressed, the Arduino randomly selects one of the three choices for the computer.
The OLED then displays:
The Arduino compares both choices and determines the result.
Game Rules
The normal Rock Paper Scissors rules are used:
PlayerComputerResult
Rock
Scissors
Player Wins
Paper
Rock
Player Wins
Scissors
Paper
Player Wins
Same Choice
Same Choice
Draw
All Other Combinations
Computer Wins
Program Features
- 128×64 OLED display
- Two-button control
- Three selectable choices
- Random computer choice
- Automatic winner detection
- Draw detection
- Simple game interface
- Uses INPUT_PULLUP for the buttons
- Uses Arduino's random() function for the computer
Downloads
Conclusion
The Rock Paper Scissors project demonstrates how an Arduino Nano can combine buttons, OLED graphics, random numbers, and conditional programming to create an interactive game.
It also demonstrates the use of if, else if, functions, variables, and random number generation in an Arduino-based embedded project.