Illustration by Megan Hellwig
Illustration by Megan Hellwig
For more on microcontrollers and wearables, check out Make: Volume 43.  Don't have this issue? Get it in the Maker Shed.
For more on microcontrollers and wearables, check out Make: Volume 43.
Don’t have this issue? Get it in the Maker Shed.
  • Time Required: A Weekend
  • Cost: $25–$150

Learning about technology is a lot easier when you’re having fun — and shooting at targets is fun! With this amusement park-style arcade, you’ll fire beams of infrared light instead of projectiles to trigger automated knock-down targets you can customize with soda cans, ducks, robots, or anything else you feel like toppling with a well-placed shot.

Here’s how to build it from scratch, using inexpensive AVR microcontroller chips you can program yourself from any computer.

How It Works

image06The toy gun emits invisible infrared (IR) light from an IR LED. The LED’s light spreads at a wide angle, which makes aiming too easy — so we mount it deep inside a tube to collimate its light into a narrower beam.

image03

This infrared light is similar to that of a light bulb or sunshine. To make the gun’s light unique, we program the gun’s microcontroller to switch the LED on and off 38 thousand times a second (38kHz), a frequency that doesn’t normally occur in background light.

Each target has an IR receiver that uses a phototransistor to see infrared light. When the target’s microcontroller detects the 38kHz signal from the gun, it triggers a servomotor to knock the target down.

Project Steps

Solder the IR gun’s electronics

Cut a perf board 1¾ “×½” so you’ve got 17 holes×4 holes available. Install the components on one side — the speaker (for sound effects), infrared LED, red LED (for a gun flash effect), 0.1µF capacitor, 27Ω resistors, and IC socket — then solder the connections on the bottom, following the schematic.

Connect the 2xAAA battery holder: black lead to GND (pin 14 on the ATtiny24) and red to pin 1.

Solder two 6″ wires to the trigger pushbutton, then solder these to the board too.

Build a programming adapter

To program your own chips, you’ll need an adapter to connect the AVR ISP programmer to the ATtiny24 microcontroller. You can get an adapter kit from Inside Gadgets or build one from scratch following these instructions.

Program the gun microcontroller

You will need programming software on your computer in order to use the ISP programmer. The most straightforward method is to download Atmel’s AVR studio from their website (atmel.com). Search for the latest AVRstudio, download it, and install it. The help system can be used to learn how to use the built in programmer.

Avrdude is an alternative open source programming software package. It will run on Windows, Mac and Linux, and can be downloaded at: http://download.savannah.gnu.org/releases/avrdude/

An Instructables describing the download and installation of avrdude is at: http://www.instructables.com/id/Atmel-Xmega-USBSerial-Arbitrary-Waveform-Generato/step3/Installing-AVRDUDE/

Tutorials for using avrdude are at: http://www.ladyada.net/learn/avr/avrdude.html
and: https://learn.adafruit.com/introducing-trinket/programming-with-avrdude

Connect the AVR ISP programmer to your adapter and insert an ATtiny24 chip into the adapter, with its notch oriented closest to the socket’s lever.

Download the project code (see “Tools” list) and open the file irgunREV100.hex in your AVR programming software. Plug the programmer into your computer, then upload the code to the chip. Finally, insert the ATtiny24 into the IC socket on the gun circuit board.

NOTE: For this project you will leave the ATtiny24 fuses at their factory defaults (8MHz internal oscillator with divide by 8 enabled).

Prepare the gun parts

You can mount the electronics in an existing toy — an old Nintendo gun already has a trigger switch — or make a DIY gun from ½” PVC pipe and fittings as shown here. Cut the pipe to length following the diagram.

NOTE: Give a kid a collection of fittings and various lengths of pipe and you may be amazed at the various devices she will come up with.

Build the gun

Mount the electronics inside the tee fitting as shown.

Then drill a 5/16″ hole in a coupler to install the trigger pushbutton.

Build the gun, cont'd

Notch the back tube to accept the battery wires, then press on the end cap.

Verify that the IR LED is pointing straight out the barrel.

Stick the battery holder onto the back with double-stick tape, and press-fit the gun together.

Solder the target electronics

The target uses another ATtiny24 to operate a speaker, two LEDs, and a servomotor. When the IR receiver detects a shot from the IR gun, the microcontroller produces a “ding” sound effect with the speaker, flashes the white and red LEDs rapidly, and sends pulses to move the servo 90° and then return it. Use the servo to move a flag down and up again or to knock a can down.

Following the schematic, solder the IC socket to the proto board and install the IR receiver module, followed by the 100Ω resistors and then the speaker, capacitor, and red and white LEDs. Install the diode and servo connector, and solder in the ground jumper wires, then connect the 4xAA battery holder.

Program the target microcontroller

Program the ATtiny24 microcontroller using the other hex file, irtargetREV100.hex, and install it in the IC socket. Then insert batteries into the battery holder.

Build a mechanical target: flag type

For a simple target, cut a small wood block and use double-sided tape to stick the servo to one corner and stick the
 circuit board to the front edge. Secure the battery pack and loose wires with a rubber band.

For a more rugged and better-looking target, use a project box and drill clearance holes for the LEDs, IR receiver, and speaker.

Print an image to use for a target and tape it to a drinking straw. Attach the straw to the horn of the servo. Your target is ready; power it up and test it by shooting at the paper target. The IR beam should be wide enough to trigger the target’s sensor when you aim at the paper target.

Build a mechanical target: knockdown type

To knock down another object such as a tin can, mount the servo horizontally and attach a stick to strike the can.

Create your shooting gallery

Place the targets on shelves and decorate your gallery to look like an amusement park arcade. You can do this quickly with cardboard and drawings, or even sew custom cloth curtains with embroidered signs.

My infrared shooting arcade first appeared at Maker Faire Bay Area 2014. You can use it to liven up all kinds of events, from birthday parties to fundraisers to Saturday afternoons. Don’t be afraid to get creative: Place targets throughout a room or house; or hide them on furniture or shelves for kids to find and shoot at.

Just move the targets occasionally to completely refresh the game, or try longer gun barrels to make aiming more challenging.