A driver for a flashlight is a circuit board with electronic components on it. The purpose is to take power from the battery, then modify that power level using the electronics, and send the output to the LED of the flashlight. For instance, to get a strobe the driver will turn the power to the LED on and off. A Low mode can be created by turning the light on and off faster than the human eye can detect. By decreasing the amount of time the LED pulses on, the light appears to get dimmer and dimmer. This is done using a microcontroller, which is just a chip that is soldered to the driver. One chip that seems to be used pretty often is the Atmel Tiny13. Some drivers have 5 modes (Low, Med, High, Strobe, SOS) and some have only 3. The only difference is in how the microcontroller works.
So a guy who was new to flashlights but had a background in electronics figured out that he could probably reprogram the microcontroller and get whatever number of modes he wanted, and he was able to write some code in C, compile it, upload it to the microcontroller on a flashlight driver board, and it worked! That’s pretty neat because drivers don’t always give you the Low and Medium modes at the level you want and too often include the flashy strobe and SOS modes that I don’t really want.
Some lights can be programmed by the user. The AKOray K-106 that I have is a famous example of a budget flashlight with 3 programmable modes. You press the tail clicky 5 times to enter programming mode, and then set each of the 3 modes for the light. These are memorized. People love that flexibility, but the AKOray is kind of hard to find lately and doesn’t come with more recent LED’s or really have a high enough current to make LED’s their brightest. So people have always wanted to tweak that driver for more output, but keep the programmability.
Well, the guy who wrote the program for the microcontroller, also wrote a program that would give a flashlight programmable modes like the AKOray. Well, I already have a few flashlights with Atmel microcontrollers, so theoretically if I got the equipment and software to re-program the Atmel chips, I could make those flashlights programmable.
So why wouldn’t I do that? First I needed the hardware. This guy uses a $50 kit called an AVR Dragon, but there is a less expensive kit called USBasp that you can build, but you can also get pre-made ones on eBay and other places for about $12. It looks kind of like the guts of a USB flash drive, except on one end is a connector for ribbon cable. The ribbon cable has 10 wires that lead to the the different legs of the chip. If you are just programming loose chips, it is pretty easy. But to program a chip that is already soldered to a board you need to either solder wires to the legs or get a clip that grabs onto the chip and has wires where each leg of the chip is. You can get those for about $8. So I ordered those two a couple of weeks ago. I got the clip on Wednesday and today the USBasp programmer showed up.
Here is the USBasp board along with the clip and a flashlight driver board with the penny there for scale (everything is pretty small; the Atmel chip is the largest of the 4 black chips on the driver board):
For software you need quite a few different programs that all work together. The programs themselves are written in C, so you need a C compiler. Then you need something called Make that will compile the program into a file that can be loaded into the microcontroller’s memory. And then you need some kind of interface software that can write the file to the chip using USBasp. That software is called AVRdude. All of this stuff has been developed into a kit called WinAVR by electronics enthusiasts who do all kinds of neat stuff with Atmel chips. Then I found out there is a pretty neat graphical user interface (GUI) that lets you work all of those tools in a Windows interface. This GUI is called Eclipse, but you have to also download and install an AVR plug-in that will interface with the WinAVR suite. The guy who wrote the programs for the flashlights uses Eclipse, so that seems to be the way to go.
I kind of got started using all of this stuff, but when I got to the part where I was supposed to read some information from the Atmel chip using the USBasp board, I got an error and I spent the rest of the day figuring it all out.
Here is the flashlight driver board with the legs (pins) of the Atmel chip numbered:
First, you can’t just connect the clip to the USBasp board because the wires in the teeth of the clip don’t match up correctly with where the pins on the USBasp chip are. So you have to figure out where each one goes. Fortunately you can move the wires around where they connect to the clip (the black rubber sleeves slide off of pins that stick out of the clip). Also you don’t need all 8 pins, just 6 of them. However I’m still getting an error that my software isn’t finding the chip. So either I have a bad software driver for the USBasp, a bad USBasp, a bad flashlight driver, the clip isn’t making good contact with all of the pins, or I didn’t wire the clip correctly. Or something else. Right now I’m pretty stuck. I could bypass the clip altogether and try to solder ribbon cable wires to each leg of the Atmel chip, but that wouldn’t be easy given the small size.