In this intractable we will take apart a toy gun and make the sounds trigger with Processing and Arduino. With a little bit of skill and patiences, you can apply these techniques to just about any toy.


  • ProtoSnap or Arduino
  • USB Cable
  • Electronic Toy
  • Computer running Processing and Arduino Software
  • Solder
  • Wire (both stranded and non-stranded)


  • Soldering Iron
  • Screw Driver
  • Wire Cutters
  • Pen & Paper

Step 1: Power to Your Toy

You will want to figure out how much power you will need to power your toy. AAA batteries are 1.5 volts. In our case, the gun requires three AAA batteries, or 4.5 volts which will power nicely from the 5 volts that the Arduino can supply.

Step 2: Scalpel Please

Ok, so, no knifes or blades were used in this project, but you are going to need a screw driver and some wire cutters. Start opening up your toy, but BE CAREFUL not to damage any wires. The wires that you will find inside your toy are flimsy and will break very easily.

Step 3: Stop and Draw

Seriously. Just draw out what you see. I didn't make a perfect schematic, but I understood my own drawing enough to know how to put the thing back together if I had broke any of the wires off. Also, it gives you an opportunity to dig in and see how things are wired up.

Step 4: Free the People

Well, let's free the circuit board at least. Use wire cutters to snip the wires free from the battery pack, and unscrew any remaining screws. You might have to break off some plastic pieces that are holding wires on, just do it VERY carefully. Remember, we are trying to keep the wires (and other fun stuff) connected to the circuit board.

Step 5: Power to Your Board

Let's test that everything is still connected and that we can get some power to your toy guts. Make sure you are sending a very basic program to the Arduino that will allow us to use it to power our toy. Connect your negative and positive wires to the ProtoSnap in order to send power over. Once you have power to your toy guts, see if you can trigger the lights and sound. In this project, I was able to squeeze together the switches to see the lights and hear the sounds.

Step 6: Solder

Now that we know where the switches are, we can solder wires onto the toys guts to allow us to feed it into the Arduino and eventually control it through Processing. We want to solder one wire to each end of the switch. For this side we will use stranded wire as it will not break as easy as if we had used solid wire.

Step 7: Relay for Life

Now that we have the wire soldered onto the switch of the toy guts, we need to figure out how to get that into the ProtoSnap. As we have no idea what is happening inside of the circuit at this point, we need to make sure we are only giving it 5 volts of power. To do this, we are going to use a relay. What's a relay, you ask? Good Question!

I would suggest a quick read through on this awesome instructable to understand.

How Electronic Switches Work For Noobs: Relays and Transistors

Step 8: Back to the Soldering Board

The relay will fit directly into the bread board (which I did on my second switch) but you can also solder directly to the relay and wire it to the bread board from there. Remember when we figured out how our relay works? With our relay we are going to solder our wire to the center two prongs, and solder wires to the outer two prongs so that I can connect the relay to the bread board.

Step 9: Connecting

Once you have all of your wires soldered to the correct places, you want to wire into your bread board. The simple schematic here shows that you want to go from your toy guts, into your magic relay, and into the VCC and GND on your bread board.

Step 10: Something Like This

We have everything wired up at this point and are ready to dig into the code to get the toy guts to trigger off of a single key stroke on the computer.

Step 11: Fire Up Your Arduino

Copy and paste the code below into a new Arduino file. This is going to allow us to let Processing talk to Arduino.

Dimmer Demonstrates the sending data from the computer to the Arduino board, in this case to control the brightness of an LED. The data is sent in individual bytes, each of which ranges from 0 to 255. Arduino reads these bytes and uses them to set the brightness of the LED. The circuit: LED attached from digital pin 9 to ground. Serial connection to Processing, Max/MSP, or another serial application created 2006 by David A. Mellis modified 30 Aug 2011 by Tom Igoe and Scott Fitzgerald This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Dimmer *

/const int ledPin = 12; // the pin that the LED is attached to

void setup() { // initialize the serial communication: Serial.begin(9600); // initialize the ledPin as an output: //pinMode(ledPin, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); }

void loop() { byte brightness;

// check if data has been sent from the computer: if (Serial.available()) { // read the most recent byte (which will be from 0 to 255): brightness = Serial.read(); digitalWrite(12, brightness); // turn the LED on (HIGH is the voltage level) digitalWrite(13, brightness); // set the brightness of the LED: // digitalWrite(ledPin, brightness); } }

Step 12: Processing

Make sure that you send the code over to Arduino, and then let's start working in Processing. Copy and paste the code below into a processing file.

// Dimmer - sends bytes over a serial port
// by David A. Mellis //This example code is in the public domain. import processing.serial.*; Serial port; int value = 0; void setup() { size(256, 150); println("Available serial ports:"); // if using Processing 2.1 or later, use Serial.printArray() println(Serial.list()); // Uses the first port in this list (number 0). Change this to // select the port corresponding to your Arduino board. The last // parameter (e.g. 9600) is the speed of the communication. It // has to correspond to the value passed to Serial.begin() in your // Arduino sketch. port = new Serial(this, Serial.list()[5], 9600); // If you know the name of the port used by the Arduino board, you // can specify it directly like this. //port = new Serial(this, "COM1", 9600); } void draw() { // draw a gradient from black to white fill(value); rect(25, 25, 50, 50); // write the current X-position of the mouse to the serial port as // a single byte port.write(value); }

void keyPressed() { if (value == 0) { value = 255; } else { value = 0; } }

Step 13: Let's Communicate

We need to make sure your Processing and Arduino are talking to one another.

The port nuber needs to match the usb port that the Arduino is connected to. You will see a list that tells you all of the serial ports that are working on your computer. Looks something like this:

Available serial ports:
/dev/cu.Bluetooth-Incoming-Port /dev/cu.Bluetooth-Modem /dev/tty.Bluetooth-Incoming-Port /dev/tty.Bluetooth-Modem

You want to make sure that you change port number (in the example line below it is 5) to match whichever port you are running your Arduino off of.

  • port = new Serial(this, Serial.list()[5], 9600);

Step 14: Push a Button, Yo

You should be all set. If you push any button on your keyboard, you should fire off a sound and some lights from your toy guts!

<p>Fun way to use and old toy, and it's nice to combine it with current technology!</p>

About This Instructable




More by jennylynnCCA:Toy Gun Fun 
Add instructable to: