Tuesday, April 19, 2011

LightManager

One great thing about this project is that I do a lot of back and forth between hardware and software work. It's not one monolithic software project. That would feel too much like work.

I opted not to buy the arcade buttons with the built in LEDs. It seems those buttons were designed for 12V systems and I would be using 5V. I probably could have modified them. I got an LED flashlight from a Yankee Swap last Christmas. It didn't work really at all but it had about 20 5mm white LEDs. Just what I needed. I drilled holes in my translucent arcade buttons, wired up the LEDs and used my favorite prototyping tool, the hot glue gun, to secure them:

Bottom of button with hole:



With LED wired and glued in:


The output pins on the Arduino (Sanguino) can provide up to 50ma of current. I didn't have any specs for the LEDs but used Ohm's law, my multimeter and some online calculators to determine what resistor to use. At 5V a 100 Ohm resistor will cap the current at 50ma. That plus the resistance of the LED itself should keep me well within a safe range and still give me plenty of brightness.

Then I wrote a basic version of my LightManager class to blink them on one at a time so I could determine if my wiring was good and which pin went to which light. Surprisingly I struggled with this. After all my years of programming I still make some amateur errors once in a while. I wrote a case/switch statement to control which light is on. In Java I have a template that lays out the structure for me, but I'm writing this in C and so I wrote it all out by hand. And I forgot my "break" statement for each case, so it totally didn't work. But I finally figured it out and discovered that my circuit design and soldering job was perfect. Here's a shot with one light on:

No comments:

Post a Comment