Introduction: Electronic Paper Rock Scissors Game
Paper, Rock, Scissors is an old, simple game. Basically each player takes turns to make a shape with their hands and depending on the combination one player wins each round. A more detailed description of the game can be found here
The game is usually played between two people with no equipment but this instructable shows you how to modernize the game and automate the reading and scoring of rounds with gloves that sense the shapes!!
Here is a video of what to expect:
Step 1: Parts You Need
The game is built around Arduinio, 4 'FlexSensor' strips and two old gloves you don't mind losing. There are some other parts too so the full list is:
- 1 x Arduino Uno
- 4 x FlexSensors 2.2" strips like these. They were apparently the sensors used in the original Nintendo Power Glove and basically act like variable resistors
- 2 x Right hand gloves. Cheap or old gardening / DIY gloves are best, you need to be able to sew into the fingers
- 6 x LEDs, 3 Blue, 3 Red
- 6 x 470 Ohm Resistors (for LEDs)
- 4 x 20k Ohm Resistors (for FlexSensors)
- 1 x 5V Piezo Transducer Buzzer - Like this example
- 4 x 1 meter (3 feet) 2-core wire
- Vero board - or breadboard if you want it a bit less permanent
- about 20 wires to connect the Arduino and the breadboard or veroboard
- 1 x small box - To house it in. I used a plastic box that the flexsensors came in but any small box will do
- Some soldering skills!
Step 2: The Gloves
First solder a 1 metre length of the 2-core wire to the two ends of a FlexSensor strip. Use heat shrink or electrian's tape to insulate the connections from each other. It should look like the picture. Repeat this 3 more times so you have 4 sensors on 4 lengths of 2-core wire.
The next step is to fix the FlexStrips into the gloves. When you think about it all 3 possible shapes (Paper, Rock & Scissors) can be determined if you know what the middle two fingers are doing
Therefore you need to sew in two sensors into each glove over the two middle fingers. You want the middle of the strip roughly over the main knuckle in each finger to get the best read. You can also use some super glue for this step if you like but it is harder to switch out a sensor then if one fails.
Lastly group the 2 lengths of wire that come out of each glove. You can put some stitches around it in the first 2-3 inches to keep it attached to the glove then after that attach the two wires for each glove together with zip ties or electrician's tape. this means that each glove only have on cable then attached with 4 cores. The other end of each needs stripping ready to solder into the veroboard
Step 3: The Circuit
Before building out the rest of the project I highly recommend trying it all out on a breadboard first before building it out on the veroboard and soldering it together. I include a picture of my messy prototype on breadboard although this really helps get the cirtcuit right and test the components
I am not going to explain each detail but I have instead included a kind of circuit diagram to show how all of the components are connected.
Some notes on this:
- If the fingers or not in the exactly right order it can be corrected later with the code
- You can use other outputs. I used 13 for one of the LEDs so this also flashes while the code is uploading
Step 4: The Code
Once you have built out the circuit (hopefully on breadboard at first) it is time to test out the code. Luckily for you I have attached my code so you don't have to write it but you might need to adjust it and you can certainly extend it. The code is fairly simple
Load the code onto your Arduino Uno Board. If you don't know how to do that I suggest reading this first
About the code:
- The code causes the buzzer to make a series of beeps. In each group of beeps the third beep indicates that the gloves are being read
- There is debug code that writes out to the serial monitor. In the Arduino code editor click on Tools > Serial Monitor first. This will tell you what the circuit is reading and who it thinks won. An annotated example is included here
- "NOREAD" in the SM output indicates either an unexpected shape is encountered (only ring finger bent) or something else went wrong with the read
- The parts of the code that look something like this "((flexSensorReading <=400) && (flexSensorReading2 <=350))" are testing whether the flex sensor has exceeded a threshold, i.e. is that finger bent or not. Depending on what reads you get in the monitor you might need to adjust these thresholds. Also this monitor can be used to determine if the fingers are wired up the same way as intended in the code.
- You can change this line "boolean soundOn = true;" to "=false" to turn off the buzzer beeping if it is annoying you while testing / debugging
- The gameMode variable is not used but I will describe what the idea was here in the next and final step
- The code scores each player up to 3 points since we only have 6 LEDs (3 each) at that point the celebrate function is called to sequence the LEDs and then flash the winners set of LEDs. Try changing this if you want a different celebration with the beeper too!
Step 5: Possible Further Work
I packaged the project in a plastic case and cut holes for the LEDs, glove wires and the USB cable. I used a mini label printer to label the 2 sets of 3 LEDs and then sealed with more tape. This is really all you need to do but if you want to do more then here are some ideas on how to carry on with other tweaks:
- The game mode 'Chaos' is not coded but the idea is that there is no audio cue as to when the glove read is taken. This means you have to try to stay ahead of your opponent at all times so that when the program randomly samples the gloves you are in the winning position. The idea would be to put a switch on the circuit so the players could select the game mode and this would be read by the Uno
- Currently there is no way to restart a game again once started. You could alter the program to read only ring finger bent on both gloves as a kind of start again instruction. Only ring finger bent is otherwise not a valid shape
- I have 6 LEDs, 3 for each player but there is enough outputs on Arduino to extend this to up to 7 for each player if you like
I hope you have fun both building and playing Electronic paper, rock scissors!
If you like this instructable please consider voting for it in the microcontoller contest!
Thanks for reading
Participated in the
Microcontroller Contest 2017