Tuesday, September 30, 2014

ZombieLARP Nerf Gun

© Paul White 2016

See the Imgur album here.

This was a side project I did during the Summer of 2014. My friend and I were attending a Live-Action Roleplaying (LARP) event nearby. This time, the theme was 'Zombie Apocalypse.' As part of the game, people were encouraged to bring their own Nerf weapons. At the beginning of the game, referees would assign damage levels to each weapon based on how cool they thought it was. Since higher damage -> more dead zombies, my buddy and I decided to kit out our Nerf guns to make them more impressive. The mods included re-painting, and adding a digital display to indicate number of shots fired, and current battery voltage, to indicate when new batteries should be installed. This short video illustrates the functionality:


Let's dig into the guts of how this thing works. This dartgun is a modified Nerf N-Strike Stryfe. This gun was selected because it uses an electric motor to accelerate darts as opposed to air pressure. This means it is fully automatic and could (in theory) have its motors over-driven to accelerate the darts even more quickly. We didn't end up going down this road, but that could be a future project. The logic is implemented on an Arduino Pro Mini clone, as shown in the extremely high-end schematic below. If you want to build a project like this for yourself, the source code is available for you to play with. This microprocessor was chosen for 4 main reaons:
  1. It was cheap as borscht
  2. It had a built-in voltage regulator, so that was one less thing to worry about dead-bug wiring in.
  3. It was an Arduino, so it was super easy to program.
  4. it was nice and compact, and would be easy to cram somewhere on the Nerf gun's body.
Here are the schematics of the hardware we used. The voltage divider on pin A7 is used to sample the battery voltage, we divided it down so that it would be within the sampling range of the microprocessor's analog-digital converter.
ZombieLARP Nerf Gun Schematic
ZombieLARP Nerf Gun IR LED schematic

Here's a cross-section of the finished dart gun. Note how I painted the interior of the magazine bay: this was so the gun wouldn't look stupid with the magazine removed. Note the seven-segment displays and accompanying circuitry in the transparent compartment at the rear, and the additional wiring on the motor module:
ZombieLARP Nerf Gun Cross-Section
The darts are counted using a simple IR LED and wavelength-matched phototransistor. The LED is always on, and the phototransistor is blocked momentarily when a dart passes through the muzzle on its way to smoke a zombie. (Note that this required me to cut a small notch in the muzzle to allow the phototransistor to see the LED) This assembly is shown in eye-searing detail in this image:
ZombieLARP Nerf Gun IR Detail
My friend and I wanted to patch the sensing/control circuitry into the Nerf gun's original power circuitry, so we could mooch off the batteries. This was done by wiring the VCC/ground pins in parallel with the rest of the gun's circuitry. The Nerf gun is basically wired as a bunch of switches in series, and if all the switches are closed, the motor circuit will be completed and the two motors will spin and shoot darts. This actually ended up causing a problem for us, since the motors would draw so much current from the batteries that the voltage across the batteries would drop below the microprocessors operating voltage of 5V as they encountered resistance accelerating a dart. This bug was discovered days before ZombieLARP was supposed to start, so we resolved it by simply placing a bunch of capacitors hat I had on hand across the batteries, to smooth the voltage and maintain the necessary 5 V. (this is the 1mF capacitance in the first figure)

The sensor switches are located in the following locations:
  1. Magazine Detector
  2. Jam door
  3. Trigger (button underneath actual trigger. If the other sensors are depressed, pushing this button will cause the motors to spin up)
ZombieLARP Nerf Gun Motor Circuit Detail
Note that this is NOT the original order of operations, we modified it so that the magazine detector would come first, so that it could be sampled by the microcontroller to detect if a magazine was present.

I hope you enjoyed this expose!

Here are the libraries/datasheets for the parts we used:
Seven Segment display: http://www.lumex.com/specs/LDD-C514RI.pdf
SevenSeg Library: http://playground.arduino.cc/Main/SevenSeg

Wednesday, September 10, 2014

ArduIMU-based Home Automation System

© Paul White 2014
For our Final Year Design Project (Capstone project), my team and I designed and implemented a framework for remote automated environmental monitoring and control. We implemented our framework in a simple home automation system based off a wireless network of peripherals. The peripherals are based on early prototypes of the upcoming ArduIMU v4 (https://www.kickstarter.com/projects/494937902/arduimu-v4-an-arduino-based-integrated-measurement). It should be noted that we used stripped-down units with all of the sensors removed; this was done to keep the unit costs low and to make them less time-consuming to assemble.

The network is managed by a PC which acts as a server. The server can receive messages from paired peripherals and also send them commands to do things. From the user’s perspective, we abstracted these messages to triggers and actions.

Users can define Services using the UI. Services allow users to attach one or more actions to a collection of one or more triggers, much like how IFTTT works (https://ifttt.com/wtf). The difference is that we allow combinations (e.g. if the temperature is > 27 degrees Celsius on AND the front door is closed, THEN activate the air conditioner)
Our demonstration system consists of a number of different peripherals including:

1.      Mains relay: A PowerSwitchTail (http://www.powerswitchtail.com/Pages/default.aspx) is connected to a digital I/O pin of the ArduIMU v4 and can switch 120V A/C applicances on and off.

2.      Switch box: This box contains 3 binary toggle switches and a potentiometer. It demonstrates consuming both digital and analog inputs.

3.      Light Strip: This is an Adafruit light strip. It demonstrates more complicated software running on the ArduIMU v4 and communicating over an SPI bus.

4.      Light box: This light box contains 5 differently colored LEDs that can be turned on and off. One LED can be dimmed too to demonstrate the PWM capabilities of our system and the ArduIMU v4.

5.      Compound peripheral: This peripheral has both inputs and outputs. It attaches to up to 2 PowerSwitchTails, a magnetic reed switch and a piezo buzzer. The user can create an intruder alarm service that consumes the trigger caused by the reed switch opening, and starts the buzzer beeping.

The fully functioning system can be seen in this video:

For those of you with too much time on your hands, check out our final report here.