January 18, 2017

Following up my previous posts breaking down some of the parts for the Arc Grenade and showing some of the wiring, I thought it would be appropriate to share the code running the Arc Grenade. Please note that I am in no way going to pretend like I’m a good programmer – there’s probably a lot of bad habits encapsulated in the lines below. That said, if it works, it works, right?

This was written with the Arduino Pro Mini 5v 16Mhz in mind. The reason I used this chip is twofold: First, it has plenty of onboard memory, which means I don’t have to fight to pare the code down to barebones. Second, it runs an ATMega 328P processor and is AVR-compatible, meaning that the Arduino library’s tone() function works without any issues. On something smaller like the ATTiny85 that you’d find in an Adafruit Trinket, the stock tone() function does not work, and you have to go to significant lengths for a workaround.

This code uses Adafruit’s NeoPixel library, because it is excellent and does what I am not smart enough to do. If you have not installed this library, make sure you do.