Posts Tagged ‘nerf’

Light Break Sensor for Ammo Counter

Thursday, January 21st, 2016

I have offered ammo counter kits for nerf dart guns for a while now.  With a tweak to the ammo counter software’s min time between fire events and the addition of a photo sensor, you can install my ammo counter kit on a nerf gun and keep track of shots remaining in your clip even while full auto firing.

What allows this to work is a light break sensor.  The part number I recommend is the OPB100Z.  It comes with an IR LED and a Phototransistor.  The LED creates a beam of light, and the phototransistor acts as a switch.  When the light shines on the sensor, the transistor conducts and the ammo counter reads voltage.  However, when a shadow is cast on the sensor the circuit is broken and the ammo counter fire input is grounded.

More info on how Phototransistors work: http://learn.parallax.com/node/258

Below is how to wire the light break sensor into an ammo counter.  The wire leads on the light break sensor are color coded, follow the colors in the diagram below.  Place the sensor and light on your barrel so each dart fired creates a shadow between the sensor and light.

Notes:

  • During your install and testing, you will be unable to see the light with your eyes.  Your human eyes are not sensitive to IR light.  Instead, point a camera or smartphone at the light and you should see the white/blue light on the screen.
  • I do not currently sell light break sensors, but do tell me when purchasing a kit that you intend to use one.  I will program with special software and include the extra two resistors seen in the diagram.
  • Places to buy a light break sensor, part number OPB100Z:

Cropped - Light Break Sensor Wiring Diagram for Ammo Counter

DIY Ammo Counter

Monday, December 21st, 2015

Do you need an ammo counter circuit for your project and are bummed that you have to wait for a spot in my build queue to open up?  Fret not, here is a step by step how to make one from scratch!

In this guide, I will detail how to build your own ammo counter for ~$25 and with only minimal soldering experience.

 

title

Parts:

You can use other arduinos or switch and display choices.  The linked ones were chosen for number of pins and size.  This project uses 16 IO pins from the arduino and the trinket is the smallest arduino that can be programmed over usb.

If you get a different display, it must have the following traits:

  • Common Cathode, the common pin is ground (do not want Common Anode)
  • Two Single Digit 7 segment displays, with 10 pins on the back EACH.
    - OR -
  • One Dual Digit 7 segment display that is non-multiplexed, with 18-20 pins on the back (multiplexed only has ~10 pins)

Wire Display to Arduino:

Get out your solder iron, wire strippers, and some note paper.

  • Wire display digits 1 and 2 as shown below, diagram only shows one digit for simplicity.
    • The common pin (CC) goes to ground.
    • The period (DP) can be left unwired.
    • Each segment is wired to a unique pin on the arduino, can use any arduino pin marked as D or A.
    • The exact pins wired to are important, write them down for later.  To run the software without modification, use the default pinout table below.
    • Diagram shows resistors between the display and the arduino.  When using the 3.3 volt version of the arduino trinket, no resistors are needed.

 

wiring

 

Default Arduino Pinout

Arduino Trinket I/O Signal Type Name
3 ~3 O Display Output Digit 1, Segment E
4 4 O Display Output Digit 1, Segment D
5 ~5 O Display Output Digit 1, Segment C
6 ~6 O Display Output Digit 2, Segment E
8 8 O Display Output Digit 2, Segment D
9 ~9 O Display Output Digit 2, Segment C
10 ~10 O Display Output Digit 2, Segment B
11 ~11 O Display Output Digit 2, Segment A
12 12 I Switch Input Fire Switch
13 13 I LED Output LED
14 A0 O Display Output Digit 2, Segment F
15 A1 O Display Output Digit 2, Segment G
16 A2 O Display Output Digit 1, Segment B
17 A3 O Display Output Digit 1, Segment A
18 A4 O Display Output Digit 1, Segment F
19 A5 O Display Output Digit 1, Segment G
RST RST I Switch Input Reload Switch

Finish Wiring Assembly:

  • Wire the fire switch to a digital pin and ground.
  • Wire the reload switch to the reset pin (RST) and ground
  • Wire in the trinket to a 3.3 – 5 volt battery pack, blue and white color displays requires minimum of 3.2 volts.

Program Software:

You will need a micro usb cable.  No batteries needed yet, the trinket is powered by the usb for now.

Source Code: codebender.cc/sketch:207738

  1. Follow the getting started guide from codebender to setup the website to talk to your arduino trinket, choose Adafruit Pro Trinket 3V USB when asked
    codebender.cc/static/walkthrough/page/1
  2. Open source code link
  3. Click Run on Arduino
    • If you get the error message, make sure to press the button on the Trinket to activate the bootloader before trying again.

Optional Software Changes

With the source code open on the codebender.cc website, find and click the edit button to make changes to the software.  After you have made changes, click Verify Code and resolve any issues, proceed to ‘Run on Arduino’ when the website indicates ‘Verification successful!’

  1. If you did not use the default pinout, you must update the pinMap list with where you wired each display segment. Use the pin numbers you wrote down
  2. If you want to use a different starting ammo count or firing types, scroll down and update ‘Starting Values’.
    • shotmode can be set to CONT for full auto or BURST for semi auto
    • burst_value is the number of ammo shot in each burst, default is 1.
    • counter_value is the starting ammo value.

Examples:

  • shotmode = BURST; burst_value = 1; counter_value = 99; is used for paintball or nerf
  • shotmode = CONT; burst_value = 1; counter_value = 60; is used to match a Halo AR MA5B
  • shotmode = BURST; burst_value = 3; counter_value = 36; is used to match a Halo BR55

Testing:

On startup, you will see the starting count of MODE1. Press the fire button and the number will go down 1 tick until 0.  The LED (pin 13) goes dark when the counter reads 00.
Press the reload button and the display will go blank, and then reset to the starting count.

Hold the fire button down while pressing reset, this will change between modes. Display will report the mode number as F1, F2, F3, and so on.

Feel free to play with the software further to tweak the features to your liking. Have fun :)

 

Ammo Counter Assembly Instructions

Friday, February 20th, 2015

Counter Assembly

DIY assembly guide for the ammo counter.  If you ordered an unassembled circuit kit, this is the instruction page for you.

Assembly order is from the center outward to minimize solder bridges.  Keep some solder removal braid handy to remove any bridges between pads.

BACK OF THE PCB

  1. Install the IC, making sure to orient with pin1 indication on the PCB
  2. Install the three resistors.
    1. 2x 10k on the bottom
    2. 100 ohm on the top
  3. Install the LEDs and bend into position to match your install location.
    1. LED on top center position (unmarked)
    2. LED on bottom marked position.

Note: The LED polarity is not marked on the board. See the wiring section for additional help.
You can also look at the copper traces that connect to the LED socket.  The ground is connected in multiple points.  The positive is connected to a single trace.

  1. Install the capacitor to the top of the PCB.

 

FRONT OF THE PCB

  1. Install the diode, leave the leads long and do not solder yet.
  2. Install the display but do not solder yet.  Orient the same as the graphic 8.8.
  3. Bend the diode down and out of the way of the display.
  4. Solder the display and diode.

WIRING

+---------------------------+
|+-------------------------+|
||  +-----+      +-----+   ||
||  |     |      |     |   ||
||  |     |      |     |   ||
||  +-----+      +-----+   ||
||  |     |      |     |   ||
||  |     |      |     |   ||
||  +-----+ .    +-----+ . ||
|+-------------------------+|
|1 2   3 4   5  -====-  8 9 |
+---------------------------+

+---------------------------+
|           11 10           |
| .  .  .  .  .  .  .  .  . |
|    =.1uF=          =100=  |
|---------------------------|
|\   ATTINY2313            ||
|/                         ||
|---------------------------|
|  =10k=             =10k=  |
| .  .  .  .  .  .  .  .  . |
|9 8   7 6    5    4 3   2 1|
+---------------------------+

Signal Name Location Ground
FIRE SWITCH 1. Fire Signal 2. Ground
AMMO AVAILABLE LED 3. LED + 4. Ground
POWER 6. Battery + 7. Ground
RELOAD SWITCH 9. Reset Signal 8. Ground
Top LED (Always ON) 10. LED + 11. Ground
Muzzle Flash 5. FX

 

Note: Power socket overlaps with the diode.  Be careful not to short.

 

TESTING

  1. After connecting power, you should see the display light up with the current clip size.
  2. Press the fire button to decrement the ammo count.
  3. Press the reload button to reset the count.
  4. When the count reaches zero, the Ammo Available LED will turn off.
  5. Additional fire modes are accessed by holding the fire button while pressing reset.  Display will read F1, F2, F3 to indicate the selected fire mode and clip size.  Release the fire button to save your selection.

 

PCB Trace Reference

This section is useful for modification and troubleshooting.  You can see where the trace wires go on the pcb.

Top

Counter_3.11 FRONT_PCB

Bottom

Counter_3.11 BACK_PCB

Reference Pictures

Additional pictures are on flickr.

 

Final assembly.  Shows placement of diode below the display.

Counter Assembly

 

Display is not soldered down yet.  LED leads bent to match install positions. Shows orientation of chip.

Top resistor pictured is 150 ohm, kit includes 100 ohm.

 

Counter Assembly

 

Orientation of display to front

Counter Assembly