Rock Paper Scissors Robot (w/ Arduino)
72 Views, 1 Favorites, 0 Comments
Rock Paper Scissors Robot (w/ Arduino)
Hello! In this Instructable, I will show you how to make a rock paper scissors robot!
It's always fun to relive your childhood by playing one of the most popular games ever, rock paper scissors. This robot allows you to play regardless of whether or not you have friends to play with. Pretty cool, huh?
Rock paper scissor needs 2 people to play, but here you are one person and the other is this device.
This interactive project was made for those who are introverts or struck with boredom. Or maybe those who are tired of their cheating friends.
How it Works:
When the slide switch is pushed and the user moves their hand close (<5 inches) to the distance sensor, the circuit will move a random sign up after 2 seconds: rock, paper, or scissors. Each sign will have its corresponding LED that will light up when the sign goes up. The circuit can also be switched on and off using the slide switch in the corner.
To quickly summarise, in this project you will create a circuit and a frame to create a functional and stylish bored-game (pun intended).
Supplies
Here is a list of items you will need to complete this project:
- Arduino UNO
- 1-2 Empty Cardboard Boxes (or regular cardboard)
- Black Paint
- Glue/Hot Glue
- Plastic Servos (x3)
- On-off switch
- Small Breadboard
- Jumper wires
- Ultrasonic sensor
- Red LED
- Green LED
- Yellow LED
- 330 Ohm Resistors (x2)
- 1k Ohm Resistor
Create the Circuit
Above is the schematic of the circuit in this project.
For extra clarification, here are the steps broken down:
Arduino Uno:
Before adding any extra components, the Arduino must be wired to the breadboard.
A jumper wire will be used to allow the Arduino to give the - rail ground. As for the + rail, the slide switch has one leg connected to it, and the middle leg is connected to the Arduino in the 5V pin. Jumper wires will also be used to connect both + rails and - rails together.
Servo Motors:
Each micro servo has 3 input pins: Positive, Negative and Signal.
Positive and negative pin of all 3 servos will be connect to + and - rails of the breadboard respectively. The signal pin of servos will be connected to 3, 6, and 9 pins on the Arduino Uno.
Ultrasonic Distance Sensor:
The distance sensor has 4 pins: Gnd, Trig, Echo, & Vcc.
Gnd needs to be connected to the - rail and Vcc needs to be connected to the + rail.
In this circuit, Trig is connected to pin 11, and Echo is connected to pin 10.
Breadboard*:
Place 3 differently coloured LEDs (in this case red, green, and yellow) at an equal distance apart.
Each LED has an anode and a cathode.
Every cathode will be connected to the - rail with a resistor in between**, and the anodes are connected to the 8, 7, and 5 pins respectively.
*Extra jumper wires were added on the breadboard to make the circuit more well-organised. They are not necessary.
**Resistors ohm amounts can vary depending on the voltage used by each LED. In this circuit, the red LED used a 1k ohm resistor, while the green and yellow LEDs used 330 ohm resistors.
Coding the Circuit
Attached is the Arduino code for the Rock Paper Scissors Project. It can be downloaded and then uploaded to the Arduino.
To understand the code, here is a breakdown of the three main functions used:
checkDistance:
Check distance does exactly what its name says, it checks the distance using trig and echo from the distance sensor.
If & Switch (Case) Statements:
An if statement was used with the condition of when the distance from the nearest object is less than 5 inches. If this condition is met, then the switch statement will be executed. Very similar to if statements, switch statements execute different areas of code depending on the value of a variable. The variable used here is "gameMove", a variable that is assigned a random number from 1-3 (rock, paper, or scissors).
Downloads
Building the Frame
To hold the circuit, a case was made out of cardboard. The electronic components come in standard sizes you can use these dimensions without worrying about fitting issues (unless using a different sized breadboard).
The dimensions of the pieces I used are as following**:
Base/Top: 2 pieces (0 x 5.5 inches)
Sides: 2 pieces (10 x 1.5 inches); 2 pieces (5.5 x 1.5 inches)
You can then hot glue the pieces to create a carboard box. It can be left at that, but to give it a more appealing look I painted them black using normal acrylic paint that can be found at the dollar store.
Finally, print out or draw symbols for rock, paper, and scissors and glue them to popsicle sticks.
**To make it easier, you may dismantle old snack boxes and hot glue them together, as this was the method I used.
Adding the Components to the Frame
This step is relatively straight forward. Cut holes with a box cutter (or poke holes sharp pencil) at the back of the circuit to make the wires more organised.
Before fixing the components inside the frame test the circuit to make sure it is working; if you miss anything fix it first.
To avoid any components falling out, use a small amount of hot glue before putting the components on the base.
Add the slide switch on the top of the frame to easily turn the circuit on and off.
Lastly, add in the rest of the components (servo motors, distance sensor, and LEDs) that should be sticking out and hot glue them to the frame.
And voilĂ ! The project is finished.
How It Works
It is very simple to use this project:
- Just switch on the circuit using the slide switch
- Bring your hands close to the sensor and start making a rock, paper, or scissor sign with your hand
- The device will raise it's own sign, as well as turn on it's corresponding LED
- The signs from the device will be random, hence you can't predict the next move
- Show this project to your friends to impress them
Now you have a skilled partner to play rock paper scissors with at home alone. Enjoy!
Video Guide
If any of the physical steps were confusing or you need a visual, here is a video made to help you follow along.
Goodluck!