Pikachu's Procedure (Adapted From Operation)
by makerhenry in Circuits > Arduino
132 Views, 3 Favorites, 0 Comments
Pikachu's Procedure (Adapted From Operation)
Pikachu's Procedure is a reimagined version of the game Operation. Pikachu has gorged itself on items at the Poké Mart and needs medical attention! Retrieve the items carefully or risk making Pikachu angry. If an item contacts the copper wire-lined hole, one of three Pikachu sounds will play at random.
In contrast to other DIY Operation games, this project uses minimal hardware because the sounds play from a connected computer.
Made for EDUC 237: Learning, Making, Crafting & Creating.
Supplies
- 1 computer
- 1 Arduino Uno
- 2 alligator clips
- 2 wires
- 1 USB 2.0 cable type A/B
- Material to be laser cut. I used MDF.
- Copper tape
Laser Cut the Game Board and Pieces
Upload the attached file to your preferred laser cutting software. The yellow lines will be cut and the dark areas will be engraved. I used the Glowforge and entered the following settings:
- Cut (Yellow): Speed 160, Power Full, 1 Pass
- Engrave: (Black): Speed 1000, Power 80, 1 Pass
Downloads
Applying Copper Tape
Surround each of the game pieces and the holes in the game board with copper tape. The copper tape is delicate, so be careful and ensure that it does not tear when applying it.
Wrap a second piece of tape around the top and bottom of each game piece and leave a little extra sticking up from the top. This is the part that the player will grab with an alligator clip.
Then, connect each of the holes with copper tape on the back of the game board and extend the tape to an edge. This is where the second alligator clip will connect the game board and the Arduino.
Connect the Arduino
Insert one end of a wire (green in the photo) into the Arduino's pin 2 and connect the other end to an alligator clip (white). The other unconnected end of the alligator clip will be used to pick up the game pieces.
Insert a second wire (white) into the Arduino's GND pin and connect the other end to the second alligator clip (white). Connect the other end of the alligator clip to the game board by clamping it on the end of the copper wire in Step 2.
Connect the Arduino to your computer with the USB cable.
Program the Arduino
From the Arduino IDE on your computer, upload the attached code to the Arduino Uno. Make sure that the operationPin is the same as the pin connected to the alligator clip that will pick up the game pieces (Here, it is number 2). Also be sure that the IDE is configuring the correct board by selecting "Arduino Uno" in the dropdown menu Tools –> Board –> Arduino AVR Boards. Take note of the USB port being used in Tools –> Port as well. We will need this in the Python script in Step 5.
Upload the code to the Arduino by clicking the Upload button in the top lefthand corner.
When running, this code constantly checks whether the circuit has been completed (i.e. a game piece has contacted the side of a hole). When that happens, it sends a signal of "1" to the computer. In the next step, we will run the Python script on the computer that will "listen" for this signal and play a sound.
const int operationPin = 2;
bool operationCompleted = false;
void setup() {
pinMode(operationPin, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
if (digitalRead(operationPin) == LOW) {
operationCompleted = true;
}
if (operationCompleted) {
Serial.write(1);
operationCompleted = false;
}
delay(50);
}
Downloads
Format the Python Script
Open the attached Python script in the IDE of your choice. I used PyCharm. Install the serial, pygame, and random libraries if you haven't already.
Paste the serial port that you identified in Step 4 inside the single quotes in line 5.
Download the attached Pikachu sounds, copy their file paths, and paste them in lines 9–11.
import serial
import pygame
import random
ser = serial.Serial('YOUR SERIAL PORT HERE#', 9600) # replace with appropriate serial port name
pygame.mixer.init()
sounds = [
# "Path to Pikachu1.mp3",
# "Path to Pikachu2.mp3",
# "Path to Pikachu3.mp3"
]
while True:
if ser.read() == b'\x01':
sound_file = random.choice(sounds)
pygame.mixer.music.load(sound_file)
pygame.mixer.music.play()
Play the Game!
Run the Python script and use the alligator clip with the one unconnected end to retrieve pieces from the game board!