I was inspired by the Awesome button done by Matt Richardson of Make Magazine. The instant I saw the Awesome button, I wanted to build one, but I had different goals in mind. I also had an extra Teensy since I ordered two when I converted a Nintendo controller to USB using a Teensy. When I bought them, pjrc.com had an micro-SD card reader as well, so I picked one of those up for cheap.
My goals were:
- Make a project similar to the Awesome button.
- Incorporate SD card functionality.
- Make something that looks nice.
- Build something that I will use. I didn't want to do a project just to do a project.
Step 1: Supplies
- a Teensy 2.0 available at (http://www.pjrc.com/store/teensy.html) for $16
- an SD adapter available at (http://www.pjrc.com/store/sd_adaptor.html) for $8
- a pink LED (parts drawers at Radio Shack)
- a blue LED(parts drawers at Radio Shack)
- 220 ohm resisters (I didn't have any, so I just used 330 ohm resisters. LEDs are still pretty bright.)
- a pink arcade button (http://www.adafruit.com/products/473) for $2.95
- a blue arcade button (http://www.adafruit.com/products/476) for $2.95
- some prototype perfboard. (Radio Shack)
- male and female headers.
- Some arduino shield stacking headers. (https://www.adafruit.com/products/85) $1.50
- Some wire. (Savaged mine from a Nintendo controller cord left over from a USB Nintendo controller conversion.)
- solder and a soldering iron
- a miniusb cable (monoprice.com)
- some kind of enclosure (Radioshack)
- adhesive labels and a printer.
Nice to have:
- a solderless breadboard
- hot glue gun
- some breadboard jumper wires.
- solder braid in case of mistakes.
Step 2: Attach the SD Adapter to the Teensy
However, I put regular male headers on the SD adapter and used arduino shield stacking headers on the first five pins of the Teensy closest to the usb port. On the remaining pins of the Teensy I put male headers. That way I could use the Teensy on the breadboard.
Step 3: Install the Development Environment.
Install the Arduino software. Please refer to the arduino site for further information: http://arduino.cc/en/Guide/HomePage
There is also simple plugin that allows you to install newly compiled sketches to the Teensy, so download Teensyduino and the Teensy Loader application. Please refer to the teensy's website for further information: http://www.pjrc.com/teensy/index.html
Once the software is installed, test your Teensy with a blink sketch and test the sd adapter with a sketch using the SD library.
This project also uses code from the SDFat library available at http://code.google.com/p/sdfatlib/ so install that to your Arduino library folder.
Step 4: Breadboard the Project
For the prototype, I used regular push buttons instead of the arcade buttons, but that is an optional step. I also put LED holders around the LEDs. The important thing to remember is to make sure the LEDs are oriented with the short pin toward ground and they have resisters in series or the LEDs will be destroyed by overcurrent. There are pullup resisters built into the Teensy, so I attached the buttons directly to the input pins I was using.
Step 5: Let the Teensy Start Naming Names. Load the SD Card With Files.
For instance the males.txt file could be:
I got my base files from: http://www.outpost9.com/files/WordLists.html, but all files needed editing to get into the format I described. There are also extraneous entries that need to be edited out. However, you could use your own lists of names.
Put all three files in the root of the SD card.
Step 6: Run the Sketch
Go to Tools --> USB Type and choose Keyboard + Mouse + Joystick
Unzip the zip file in your arduino sketchbook which should be in My Documents\Arduino\
Exit and restart the Arduino software and choose the sketch CharacterNameGenerator.
Open the Teensy Loader program, then plug the Teensy into your USB port and run the sketch. It should autoload onto your Teensy.
Next open notepad or your favorite editor, then press a button on your circuit.
An LED will light and then your Teensy will find a random line from one of your gender specific files and then from the surnames and print them out on the screen.
Step 7: Building the Enclosure
First print out the graphics. (I took mine to staples and had it professionally printed.) Also, print out the graphis on plain paper to use as a guide for your drill holes. (I didn't do this and had a mess when the drill just tore up my adhesive graphics. I had to use the extra sheet I had printed.)
Next take your buttons apart. Mine had little tabs you just squeezed and the top of the button fell out. I stuck the male and female emblems on the graphics to the insides of the buttons and then put the buttons back together again.
Take a drill or Dremel tool and use it to cut out the holes for the large arcade buttons and the LED holders. Also drill a hole for your USB cord.
Then, stick the graphics onto the enclosure, insuring that you have the holes lined up where you drilled them. Cut out the part of the graphics over the holes with an Xacto knife and then pop in your arcade buttons and LED holders.
Step 8: Solder the Parts Together
First put on safety glasses. You only get one set of eyes and you only need to have one lead fly at your eye when you trim it off a resister to hurt your eyesight.
Now trim your prototype board down to the right size to fit in the enclosure. Once it will fit to your liking, solder on female header strips onto the board. Also jumper the first pin of the female header pin to the ground rail. Then fit your teensy on top of it to see how it fits.
Remove the Teensy and solder your 220 ohm resisters to pins 12 and 14 to the left and right side of the board.
Now use your wire to attach a lead to each lead of the LEDs and each lead of the buttons. Attach one wire from each of those to ground. On buttons, it doesn't matter which one, but on LEDs the short lead goes to ground.
Attach a wire from the first button to pin 7 and a wire from the second button to pin 8 of the Teensy.
Attach one wire from each resister to each LED. See the schematic for proper wiring.
Once everything is wired up, hook up the USB cable and test your work. Make sure the proper button makes the proper thing happen and LEDs light up. If you mixed up the LEDs, don't bother to resolder, just change the pins in the Arduino sketch and they should work properly. Once everthing is tested, put a dab of glue on the underside of the circuit board and stick it to the bottom of the enclosure. I also added glue to the top of the solder joints on the LEDs because I just soldered loose wire to the leads.
Step 9: Close the Box
Screw in the screws to the bottom of the enclosure to keep everything together. For an added touch, I put rubber feet on the bottom of the enclosures over the screws.
Now plug the unit in and test it one more time for good measure.
Step 10: Future Actions
Open the Arduino CharacterNameGenerator sketch and open the Teensy Loader. It should autoload a new sketch without needing access to the reset button.
In the Arduino program, go to Tools -> USB Type and choose Disk(SD card) + Keyboard
Recompile and wait for the sketch to load on the Teensy. Now the SD card appears on your computer as a disk drive. It might be desirable for you to leave it as a disk drive. Either way, it will still generate character names when you press the arcade buttons.
You are now done. Generate a name for a new character and write a story about him or her.