Introduction: Shocksweeper- a Shocking Game of Minesweeper
If you are anything like me, you probably like playing the computer game minesweeper. When playing, I've noticed that since there's no penalty for losing, I wouldn't try as hard as if there was. It's as if I was too carefree- until now. I modified an open-source version of the game in processing, so when the player clicks a mine, they are given a mild (but still quite painful) shock. It's like high-stakes minesweeper. To do this, I found cheap stick of "shocking gum" (http://amzn.to/MOgtAJ), took it apart, made it so it could be controlled by an Arduino, modified an existing open-source minesweeper processing script, and next thing I knew it, I was being shocked after losing a game of minesweeper.
Using the device is quite simple:
Plug it into your computer.
Hold onto the shocker (a small, plastic chip) with your thumb and index finger.
Run the game.
If a mine is clicked on, you will be given a mild shock lasting roughly 160 milliseconds.
No, the shock is not dangerous. It is most definitely not pleasant, and does make the game frightening, but the shocker was taken from a toy and is not truly dangerous. With that being said, though, the package warns to not use it if you're under the age of 14, or if you have a pacemaker of anything else of that sort. I am not responsible for anything bad that comes of you using this.
Oh, yes, I did mention that I did not write the entire, or most of, or really even a 1/16 of the minesweeper source code. All I did was add the shocking feature, and changed around some difficulty stuff. The credit goes to Luke Noonan, who published it under a CC-BY-NC-SA license. The original source code and stuff can be found here: http://www.acsu.buffalo.edu/~johnnoon/programming
Don't know what minesweeper is? Check out the Wikipedia page here: http://en.wikipedia.org/wiki/Minesweeper_%28video_game%29
Step 1: Supplies
Here's what you need to make it:
1 Stick of shocking gum (http://amzn.to/MOgtAJ)
1 5v Relay
1 IR receiver diode
1 NPN transistor
1 10k resistor
Step 2: Obtain Shocking Mechanism
You have to begin by stealing the shocker from the gum pack. Here's how to do that:
1. Cut off back (see picture 2)
2. Open up (see picture 3)
3. Unhook spring (see picture 4)
4. Unscrew negative lead (see picture 5)
5. Cut out battery socket (see pictures 5 and 1)
Now everything come out of the pack quite nicely.
Step 3: How the Shocking Works
Before doing anything, I needed to find out how to induce the shock. After playing around with it for a little bit, I found that when the negative lead is connected one of the sides of the shock gum (see picture for details) it shocks. This is to be expected because that will ground the circuit, thus making it complete, thus allowing current to flow through the shocking part.
From here I decided the the best thing to do would be to use a relay to connect them.
Step 4: Solder
After the explanation in the previous step, it's clear which which wires on the shocker must be put in a relay. It helps to solder extra wires on so you can use it with a relay. Solder wires as shown in the picture.
Step 5: Set Up Relay
This part is tricky. A relay switch is simply a switch that in not controlled by pressing a button, or sliding switch, but is controlled by current. If it has current running through it, it will throw a switch. I'm no electrical engineer, so I can't explain this as well as some people, but wiring a relay directly to a micro controller will drawn infinite current, and will fry your micro controller. There are many ways to stop this from happening, each person has there own strategy, but I would use the one found here:
The relay should be controlled with pin 2.
Step 6: Attach Shocker to Relay
This is fairly easy. Hook up one of the wires to the common pin of the relay, and the other to the normally open pin of the relay. It doesn't matter which wire is which.
Step 7: Arduino Code
Here's the code for the Arduino. It's quite simple really; when it receives the letter 'X' from the serial port, it throws the relay, inducing a shock. Here it is:
if (Serial.read() == 'X')
digitalWrite(2, HIGH); //Shocks
digitalWrite(2, LOW); //Stops shocking
Step 8: Processing Code
As I said earlier, most of this is not my work. It was taken from Luke Noonan and is available here: www.acsu.buffalo.edu/~johnnoon/programming/sweeper_2.pdf. To respect is CC-BY-NC-SA license, I'm going to credit him (done) and release this instructable under the same license he did.
The code is so long that I cannot paste it here, you have to download it below. I modified it so when a mine is clicked, it write 'X' to the serial port, which is received by the Arduino. Have fun.
Step 9: Sweep Some Mines
You're now ready to play! Simply plug the Arduino into you're computer, upload the code, run the processing script, and play! The game is a good recreation of original minesweeper, but does not have all the same features. Gameplay is essentially the same, so if you're good at minesweeper, you'll be good at this. You can time yourself using a stopwatch, although the shocking feature helps to improve accuracy, not speed.
Again use this at your own risk, but don't worry too much about getting shocked, it's less painful than you'd think (but still unpleasant).
Any questions, comment, or angry rants can go in the comments section, I'll get back to you pretty quickly. Have fun and happy sweeping!
We have a be nice policy.
Please be positive and constructive.