Arduino Payload launcher for Teensy

The other day I have bought a Teensy2 to play around with. My goal was to make it launch my payloads as fast and as stealthy as possible.
I have never coded for arduino and right after I received my teensy in mail I started researching and reading up on arduino programming. I was surprised at how easy it was to begin with it. The PJRC tutorial was a good starting point.
After toying around a bit with arduino language I decided to start a project. It’s simple, had to do some reading and research in the process but the final result is great. Below I’ll give the code for Teensy.

My payload launcher requires some things:

Teensy has to have an SD card adapter installed with SD card present in it. I bought one along with a teensy because it was designed for it :P to attach the adapter I used smaller pins than they sell on PJRC and wrapped around with electrical tape – that way I didn’t have to solder anything leaving contacts in tact and it still works as it should.

Teensy comes with 1 on-board LED on pin 11. That didn’t suffice my needs, so I had to install 2 separate LED’s as indicators. I used red and green ones coupled with 220 ohm resistors, attached to pins 9 and 10.
Work indication depends on a control file which must be created after your work is done. When Teensy is inserted and if there was an error initializing SD card, both, green and red LED’s will light up. If everything is OK, a red led will light up until the code starts executing – in my code it’s set to 15 seconds delay. While code is running the red LED will blink and when your work is done, a green LED will light up indicating that the work is done.

The SD card must be named as TEENSY for the code to find itself when the launcher runs.

Everything fits nicely in a match box. I glued it around with 1mm cardboard for reinforcement.

Here’s how it looks like :)

Now the code. It’s well commented, so every noob should be able to modify it to their needs. In the future I will try to make teensy directly execute a payload when it is launched instead of navigating the computer to execute it, but it is very hard on payload side due to very small internal memory size.