The debouncing is below. It just does 3 reads on the I/O pin with a 2 msec delay in between. I'm really not sure if it will do much because no idea if the time delay of 2 msecs is relevant with this hardware. I've seen other driver code that did much longer time delays, interrupt based.
// Do some simple de-bouncing checks
byte inPressed = ((PINB&8) == 0); // 0=not pressed
if (inPressed)
{
_delay_ms (2);
inPressed = ((PINB&8) == 0);
if (inPressed)
{
_delay_ms (2);
inPressed = ((PINB&8) == 0);
}
}
if (inPressed) // qualified button being pressed
...
This firmware seems to be working fine, but I tried it in my troublesome XP-11, and high mode is not working, but had the same problem with another e-switch version (Werner's), so thinking I might have messed up the LED or driver... I think I did have a short going in with the emitter, fixed it, but damage is probably done.
you’re a star DrJones and thank you for having the courage to put your hard work out there, with nothing but thanks in return. I’ve been fretting about how to turn one of my commuter lights into an e-switch light as it’s out of action due to a crappy Judco switch and this pops up. Thank you so much, it’s much appreciated.
I haven’t read this thread before. Thank you for sharing the results all your effort here for free. I’m planning to mod a light with an electronic switch, but I don’t have equipment nor knowledge to flash it myself, so I’ll take the easy route (buying one from you)
Thanks
Dear Dr. Jones,
I am thinking that the code of MiniMo is small in size which may be possible to fit in the smallest Attiny family Attiny10. I modified the code ( change PORTB=8 to PORTB=4, (PINB&8) to (PINB&4) ) to set the PB2 of the Attiny10 as switch pin and then built the hex by AVR Studio 4 but the process was failed with 2 errors. Would you please help me to correct the errors.
Thanks for your advice. I found that the Attiny13A-MMU has the same footprint as Attiny10. It is not worth for the effort to work with an Attiny10 to replace Attiny13A.