Introduction: Generate Story Character Names With the Teensy

About: I am a fiction writer who believes that if technology is truly labor-saving, we should use it to get more done.
I am a fiction writer and sometimes it is hard to come up with names for characters to use in a story.  What I did was make a USB device to come up with storybook characters at a push of a button.

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.
The Awesome button is pretty awesome, but I don't really need to come up with synonyms for awesome. The Character Name Generator is really a solution looking for a problem, but it does what it is designed to do.

Step 1: Supplies

You will need:

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

The SD Adapter is made to go right on top of the Teensy.  Therefore, it should be straight forward to put them together.  PJRC even sells a special header to attach it on top.

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.

The Teensy will work on most all computers without any software, software is required to program the Teensy.

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

Lay out the circuit on a bread board.  The picture is a bit blurry, but if you follow the schematics, you can get the circuit put together.

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.

First we need a list of names for the teensy to draw from when we press a button.  We will need three files: a list of male names, a list of female names, and a list of surnames.  Call them males.txt, females.txt, and surnames.txt.  The first line of each file needs to have the number of lines in the file and then one name per line after that.

For instance the males.txt file could be:

4
John
Jacob
Edward

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 --> Board and choose Teensy 2.0

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

Let's build 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

Here comes the part of the project that is either a lot of fun or very difficult depending on your soldering skills.

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

Close everything up, being careful not to pinch the loose wire.  I made the wire a bit long, but my enclosure had plenty of room inside.  Make sure you have the correct SD card in the SD adapter, because it will be a real pain to open the unit to change the SD cards.

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

Sometimes things change.  You might get a new collection of names and want to load them onto the SD card of your program.  You might have special purpose files for certain stories and you might want to access the SD card to change things.  Fortunately that is easily accomplished without opening the enclosure.

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.