Introduction: Arduino Rock-Paper-Scissors
Here's my version of the classic Rock-Paper-Scissors game, but it's just you against the ATMEGA328P-PU. The scorekeeper is across the top with a yellow LED for even, green LED's for the player, and red LED's for the chip. If one side gets 5 up on the other, the scorekeeper flashes for the winner. The middle Rock-Paper-Scissors LED's indicate each side's play. For now, the micro tries to just randomly pick a play, but the plan is to have it reading my mind down the road.
The version I built here is a stand-alone board, but I used the Arduino software for programming and the game can also be built using an Arduino UNO board.
Step 1: Parts and Tools
- (1) White Bread Shield for Arduino (Tinkineering)
- (1) Atmel ATMEGA328P-PU (Digikey)
- (1) 28-Position DIP Socket (Digikey)
- (1) 16MHz Crystal (Digikey)
- (2) 22pF 50V Capacitor - Ceramic (Digikey)
- (1) 1M-Ohm 1/4W Resistor (Digikey)
- (1) Power Jack (Digikey)
- (1) 1N4001 Diode (Digikey)
- (1) 5VDC 1A Voltage Regulator (Digikey)
- (1) 0.1uF 50V Capacitor - Aluminum (Digikey)
- (1) 0.33uF 50V Capacitor - Aluminum (Digikey)
- (2) 0.1uF 50V Capacitor - Ceramic (Digikey)
- (4) SPST Tactile Switch (Digikey)
- (4) 10k-Ohm 1/4W Resistor (Digikey)
- (8) 3mm Green LED (Digikey)
- (7) 3mm Red LED (Digikey)
- (1) 3mm Yellow LED (Digikey)
- (16) 220-Ohm 1/4W Resistor (Digikey)
- Hook-Up Wire
- Card Stock for Faceplate
- Wall Wart Power Supply - If you have one that works with the Arduino UNO, your power supply will work with the power jack listed above.
- Soldering Iron and Solder
- Wire Cutters for Trimming Leads
- Wire Strippers for Hook-Up Wire
- Scissors and a Hole-Punch for the Faceplate
Step 2: Lay Out the Board
I laid out the LED's and buttons for a simple interface. The scorekeeping LED's are across the top and the Rock-Paper-Scissors LED's are in the center. The buttons are across the bottom for easy access and I tried to pay attention to the layout to allow the resistors to be positioned laying down. This allows for the simple card stock faceplate to lay a little flatter.
If you look closely at the picture, the pushbuttons are turned the wrong way. This gave me a great opportunity to practice my desoldering skills.
Step 3: Generic LED Output Configuration
This shows the basic LED and 220-Ohm resistor hookup used for all the LED indicators.
Step 4: Generic Pushbutton Input Configuration
This shows the basic pushbutton and 10k-Ohm resistor hookup. You'll note the 10k-Ohm resistor pulls the Input Pin low to ground. When the pushbutton is pressed, the pin is pulled high to +5VDC. This is how the software expects the pushbutton input pins to work.
Step 5: LED and Pushbutton Resistor Layout
For each of the LED's and pushbuttons, the resistors are laid out, soldered, and the leads clipped.
Step 6: Arduino UNO I/O Pin Map
For each of the LED's and pushbuttons, here are the I/O pin designations.
Step 7: Connect I/O Pins
Start by connecting the I/O pins to the LED and pushbutton circuits. Be sure to follow the I/O pin mapping in Step 6. Also, keep in mind the LED and pushbutton circuits and where the I/O pins get connected.
Step 8: Populate and Solder the Stand-Alone Components
If you choose to use a White Bread Board, you will populate the board with the components designated on the board. Each of the parts get soldered and trimmed.
Step 9: Arduino Sketch
- Tries to pick a random play of Rock, Paper, or Scissors.
- The score is displayed on the scorekeeper.
- Waits for the player to choose Rock, Paper, or Scissors.
- When the player picks a play, both the player and software plays are indicated and the score is updated.
- If one side gets 5 up, the scorekeeper flashes the winner's score indicators and starts a new game.
Step 10: Faceplate
To dress up the game some, I made a simple faceplate to cover the board using card stock. The faceplate was drawn in Serif DrawPlus and printed on card stock. I used a little 3mm hole punch for the LED's and trimmed to size using scissors.