I'm willing to pay $200 (not commercial)

I’ve been trying to get my flashlight firmware to work with my clicky flashlight, on a driver I designed myself. I’ve probably spend about 15 hours troubleshooting this, and my time is more valuable than that so I’m going to put out a bounty for someone to assist me with this.

I’m willing to share my schematic, and firmware, and if you can point me in the right direction to get this working, I will return the favor and paypal or venmo you $200. If it takes you 1 minute to get me up and running, I’ll still pay you. It’s legit, nothing fishy, I just want my flashlight to work the way I want it to.

No I’m not going to be selling this, I just want to make myself 10 flashlights that I can leave all around my house that will be super reliable, with hardware I can trust. No I don’t want to use someone else’s driver, but I’ll consider using someone else’s firmware.

Let me know if you are interested and I’ll share the details.

I’m willing to have a look at it just out of curiosity. No money necessary.

There’s a link to the schematic. I’ve heard that Bistro will work with this type of driver. It’s being powered by 2x 18650 cells in series, so 8.4V input.

The driver itself works fine, just need help with getting the MCU working with the modes. ATtiny25 or ATtiny85, or any other compatible ATtiny device.

All i see is a 1.2v?? voltage regulator and outdated Attiny12.
Check this out, maybe youll find what you want:

So, when you say the driver itself works fine, you can drive PB0 low and get one level of output on the LEDs, and drive PB1 low and get another level of output? (This is a dual channel, right?)

Input is 8.4V, the regulator I’m using is 3.3V. The MCU, I have both Attiny25 and Attiny85 on hand, pinout is the same.

I only need one PWM channel, so I can use either PB0 or PB1.

The schematic you posted in post #3 does not give any indication on how you actually plan on switching modes. Are you planning on using a clicky/off switch or a momentary/E-switch? If clicky/offswitch, what method? I don’t see any off-time capacitor.

It also doesn’t show where the PWM outputs go. A FET? Banks of linear drivers?

It goes to a buck driver. The driver works and is a separate circuit so I didn’t include it in the schematics. Assume the PWM output goes to a functioning driver.

The switch is a clicky/on/off type where a half-press simply opens the circuit. True no off time capacitor exists because I’m unsure how to integrate one and make the calculations for the firmware. This is why I’m asking for help :wink:

So what do you have for firmware right now? Start with something simple that turns the output pin on and off every 200 ms, then add PWM and get it to drive the output at quarter / half duty cycle alternating. Can you get that far?

Well, you wrote you where troubleshooting an already designed driver, trying to get the firmware to work. As you designed the driver, how did you design the driver to work in terms of mode changing?

Yes, I can get an appropriate PWM setting. Just can’t figure out how to get the modes to change.

#Mike C
The driver is the part that regulates power to the LED. The microcontroller and it’s firmware sends the signal to control the driver. The driver is designed. I need assistance with the microcontroller and it’s firmware.

If I put in a signal to the driver, the driver does what it’s told. I’m not sure how to get the clicky button to tell the microcontroller how to change modes.

I’ve read that I need to use capacitors to allow the micro to stay on briefly between clicks/half presses, but haven’t found technical information on how to implement this. Perhaps if someone had both a schematic and firmware of a clicky (on/off switch) flashlight I would figure it out from there and that’s all it would take so I’d send that person the promised money.

Usually if the microcontroller has a normal decoupling capacitor on its supply you can use the RAM retention trick like this: Declare two variables that the compiler won’t automatically initialize to zero upon bootup:

unsigned int key attribute ((section (“.noinit”)));

unsigned char mode attribute ((section (“.noinit”)));

And then at the beginning of your loop, so that it executes once each time the processor boots up:

if(key==12345){ //check if RAM is still valid from last time

mode++; //yes, advance to next mode

if(mode>max_mode) {mode=0;}


else{ //long power loss. default to first mode


key=12345; //initialize key for next power loss


Thanks for your helpful response tterev3

I am currently using a 47uF decoupling capacitor, is that adequate our should I double, quadruple, etc the value?

For the first two lines, do I insert that before void setup? Or within void setup? I’ve tried several places and can’t get it to compile. (Or am I supposed to fill in a variable?)


You will have to test the capacitance in your system and see, there are a lot of variables with the other electronics loading down the rail. The first two are variable declarations, they should be put outside of any functions to make them global (assuming you have both a setup() and main() that will need to access them). Sorry, I think the forum formatting ruined the syntax. It should be

unsigned int key __attribute__ ((section (".noinit")));

unsigned char mode __attribute__ ((section (".noinit")));

Thanks for that, that updated syntax compiled correctly.

Is there a target capacitance that this requires? Or a certain mcu ontime after the button opens the circuit?


The trick is that there is a lower voltage limit below which the processor won’t operate, and a lower voltage limit below which RAM won’t be maintained, but they are not the same voltage. You can look it up for your specific part, but generally somewhere around 2.5V it will stop running, but it will maintain RAM values until about 1.5V. So when you open up the switch and it loses power, the voltage will start to fall. It will fall very fast at first while the LEDs etc. can still operate and draw current, but once you cross the threshold where the LEDs and processor shut off, voltage starts to fall much more slowly since nothing is drawing significant current. The time it takes for voltage to fall from this first threshold to the second is how long you have to reconnect power with the switch (or the length of your tap on a reverse-clicky). In my designs I like to target about 500ms for this time period. If you have stuff like resistor dividers, they will drain the power faster and you may need to increase capacitance to extend the time. On some designs there is almost no power drain below 2.5V and you would need to add resistance to intentionally drain the capacitor (and/or reduce the capacitance) so that the part can fully reset in a reasonable amount of time.

Where in my code specifies the length of the tap on the clicky switch? Feel free to PM me, because if we get this working soon I’ll square up with the house.