"Cry baby, cry..."
"...Make your mother sigh!"Long time no talk, Legacy! Sorry for being scarce these days. I've been meaning to put together a full, detailed, step-by-step tutorial on how I rigged up the effects in my smartgun for, well... sheesh, nearly a year now, and I'm sorry to say I just haven't found the time.
SO... rather than delay any further, I'm going to go ahead and release my Arduino code out into the wild where it might at least do some good. Hopefully one of these days I'll have time to put together a proper tutorial, but I will do my best to summarize in the meantime!
WHAT YOU WILL NEED:- 1
Adafruit "Trinket Pro" microprocessor with the LiPo battery "backpack" ($10+$5)
- 1
Adafruit 16MB Audio FX MP3/OGG board ($25, obviously only necessary if you want sound effects)
- 1
Adafruit LED Quad-Alphanumeric display with I2C "backpack". ($10)
- 1
Lithium Polymer battery. I used a 1200MAh battery ($10) and have yet to run it dry even once.
- 1 N-Channel power MOSFET
- High-power LEDs for the muzzle flash
- The Arduino IDE (aka the free program used for writing and uploading your code)
Total cost: roughly $70, plus whatever speaker you choose for sound output.
The setup is simple: The Trinket Pro is the "master" board which contains the program logic and runs the muzzle flash LEDs and the ammo counter. It also sends UART Serial commands to the audio board to trigger it to play sounds.
The high discharge rate of a LiPo battery provides more than enough power for both the Arduino boards and the LED ammo counter, and also provides the power for the muzzle LEDs via a MOSFET. Running the muzzle LED power through a 'FET instead of through the Trinket board itself allows you to use high-intensity LEDs, which require more current than the Trinket could otherwise handle without burning up. The Trinket just triggers the MOSFET "open" or "closed" to control the muzzle LEDs. This is how I was able to get that ridiculously bright muzzle flash on my SG... there's no less than 7 high-power amber LEDs in Juliet's muzzle.
THE CODE:https://github.com/outcry27/crybabyFXThis is the current "vanilla" version of the program I am using, ready to be customized. A "pin-out" list is included in the header comments in the code. It may look complicated if you're not familiar with programming, but what it does is very straightforward:
- Set up the software packages whose features it needs while running (called "libraries"; these need to be installed in your Arduino IDE program's "libraries" folder in order for the program to include them when it uploads the code to your Trinket.)
- Set up the variables it will be using, including some shortcuts to pins on the Trinket board
- Start the serial communication on the Trinket board (this is how it controls both the ammo counter and the audio board.)
- Set up the default states for the muzzle LEDs, the "safety" switch, etc.
From there it runs through a logic loop where it checks whether or not buttons have been pressed and/or certain conditions have been met (is the safety on? is there ammo left in the ammo count variable?), does certain things if they have, and then rinses and repeats.
The ammo counter loop is currently set up for 4-digit display, but can be easily simplified to two digits for a Pulse. The code is on a
honor system, free-to-use basis. You are welcome to customize it for your own use; all I ask is that you please just give attribution, and don't use it in anything you plan to sell without clearing it with me first.
______________________________________________________________________________
I will still try to put together a wiring tutorial, with pictures and the like, sometime in the future. In the meantime, this code gives you a known-working place to start from, and Adafruit.com has *TONS* of tutorials and lessons to help you fill in the gaps if you get lost.
There you have it, Marines... now
go make some noise!
_________________
CPL Sean Maio A01/TQ2.0.72156E1
Public Relations Division (Temporary Cross-Assignment)
M-56 Smartgun Operator, A/3Btn, II CMEF, USS Sephora