My modified program for Convoy S3 flashlight

I have a Convoy S3 flashlight and after following directions from various sources including this forum (for example), I think I finally got my flashlight working in a way that I like. Its still not perfect but its fine for now. If I have time again I might try some more changes.
The flashlight has a ATTiny13A microcontroller. I got the cheap $10 SOIC clip from Ebay and the USB programmer also from there for the same price.

The features are, as mentioned in the code:
// Made for Convoy S3 flashlight; should work on others with the same processor.
// Has 3 modes (low, medium and maximum) which can be changed.
// No stars. No memory. 3 seconds for saving mode. Always starts up in lowest mode.
// To use medium, click 2 times within 3 seconds. To use the max mode, click the button 3 times within the same time period (3 seconds). — Edit this to 2 seconds, it will be better.
// Light has a fade effect when turning on a mode so it turns on gradually. Its not too slow; takes just about half a second for the fade effect. Its not possible to fade out. I like this effect.
// No annoying blinky/flashy/blinding/SOS modes whatsoever.
// Low voltage code and Turbo timer was not tested after the changes

I would have done more but there’s the data and program memory limit. I’ll see how this goes but I may buy another flashlight in the future with a control ring to have an extra control option for convenience. I think I would like to see if there’s a driver with a bigger microcontroller so I can make a bigger program with more fancy features. I havent looked at what other people with a lot more flashlight programming experience have done. For example one thing I would like to do is to make the flashlight programmable with just clicking the buttons (number of modes, their brightness levels, turn on/off memory, direction, time periods, turbo/max mode time limits, use fade-in effects, some kind of gentle fluctuating power level change to show Max mode has been reached …… etc). I think I saw some programs that made the light programmable with clicks.
I wish all these flashlight manufactures could work on one nice program and use it on all their products so everyone could customize their lights easily. Better companies will start doing this first and the rest will try to follow.

I’m new to flashlight programming so whatever I say may have some errors or it could be improved so please do your research carefully to make sure you do the right thing.

Here’s the code (C language) in case anyone wants to try it out. This code is a modified version of someone else’s program (found in the unzipped directory: JCapSolutions-blf-firmware-a30f090 / Star). Copy from:
There’s some junk old code or comments that I did not clean up in case I might need to reuse or refer to it later. Some comments are not valid so if you make changes you’ll have to see what its actually doing.
Here’s the Hex file generated from that code in Atmel Studio 6.2. Download at (click the blue “slow download” button):
If you have that SOIC clip and the USB flasher and are able to talk to your device, you can just program the flashlight using the hex file.

As mentioned on the wiki, this is the command for checking if you have a working connection to the flashlight: avrdude -p t13 -c usbasp -n

This is the code for programming the light using the hex file:
avrdude -p t13 -c usbasp -u -Uflash:w:flashlight-1.hex:a -Ulfuse:w:0x72:m -Uhfuse:w:0xFF:m
If you have a hex file with another filename you have to change the name in the command. Also note the values of the fuses. If you have not programmed that specific flashlight before, you can run the command described in the Download Settings section on the wiki just so you download the original data before overwriting it.

Thanks to everyone who has made guides on how to do stuff.

Nice work!

I’ve done this with the ATtiny85. I use it in this light: I started with the 13A but in post #48 I stuck in my new driver design and put a 85 on it. I’m still working on the 85 firmware and intend to share it once I’m done. Right now I’m fine tuning the methods of mode programming, then on to the temperature sensor.

One thing you might like to look at is using the method for off time mode switching by using this method:
You would gain two things from this:

  1. You would eliminate that first press that does nothing except reset on time for mode change detection, meaning one press to medium, two for high.
  2. As your light has no memory you could scrap the EEPROM read and write routines, freeing up more space. The “noinit” variables are a sort of memory that lasts for about half a second with standard input capacitor before decaying.

In my 85 firmware I’m putting all kinds of stuff in “noinit” data, including the full set of modes for mode reprogramming, voltage levels and more. It’s a very useful method of storing data that you want to survive short presses.

Thanks for the info! I will definitely come back again to your post in the future.
Thats great, 8K of programming space instead of 1K with the same footprint and pins. Are there any drivers available with the ATtiny85 already soldered on it or do all the companies use 13A? I wish they used a better chip. People would definitely pay 30 cents more for it if needed.

Nice post there! I will follow it. Very advanced stuff. I will also look at the alternate off method.

Not exactly… The 85 is larger, but will fit on a 13A footprint if you bend the legs under the MCU. In fact, the 85 with bent legs uses slightly less footprint space then a 13A with untouched legs. This is good for me because I have a few driver designs where space is valuable. The 13A with bent legs is of coarse even smaller, but I’m done with that tiny thing. From now on all my lights have the 85, no matter what kind of light it is. My driver designs have the MCU on the battery side, so upgrading firmware as I go along is no hassle, don’t need to rip the whole light apart:



One of the ATtiny25 versions has the exact same dimensions as the 13A. That will give you 2K of space to play with. It’s an option if you insist on using the same footprint without bending legs.

Oh yes thank you for posting, ramping up to the next mode is something I would never have thought of but I can imagine it’s a nice effect.