What I'm most interested in is how this circuit switches modes (Hi-Med-Lo-Strobe-SOS).
I'm completely new to micro controllers, so I apologize if this is a dumb question, but is it possible that the Vcc pin itself is sensing the drop in voltage?
To follow up a little bit, I connected channel one of the oscilloscope to the Vcc pin and channel 2 to the main switch. When power is cut off, it looks like there's roughly 45 milliseconds before the voltage at Vcc drops below 1.8V.
Well that's about all I got. If you can help shed a little light, I'd really appreciate it. At some point once I get the hang of things, I'd like to duplicate this circuit with an ATTINY45 and stick it in a modded flashlight.
The diode and 20K resistor I suspect are acting as a very cheap regulator for the microcontroller along with the capacitor to keep things stable when the LED turns on. The PWM is used so they can vary the intensity of the LED.
Based on my parametric search, the ATTiny43U is probably the best processor for this. It operates .7v and 5.5v, and is one of the picopower processors (very low current)The only real drawbacks are that it has only 256 bytes of RAM , so you may have to write assembly (your code is so simple, I don't think you would have trouble with that), and it doesn't come in a DIP package (but does come in a SOIC package.)Also, as a tip, the slower your clock frequency, the less power the AVR will consume. And make use of the sleep() function as much as possible.All in all, the Arduino core is not ideal for this application, really. You might use it for development, but for a final application, I would look at writing assembly code.
Ah I didn't read the part about the switching modes of the LED.I agree with Retroplayer about using interrupts and going to sleep whenever you aren't toggling the LED. Also sometimes if you enable pull-ups on the pins you don't use (so they aren't floating) this can reduce power consumption too.
1) Flashlight powers on, micro checks current mode setting2) Micro increments the mode setting in eeprom3) Micro waits ~5 seconds4) Micro sets the mode setting back to current setting in eepromIn other words, if the user turns off the flashlight before five seconds have elapsed then the next mode setting will be sitting in the eeprom, and if they don't then it rewrites the eeprom back to the current mode setting.It is kinda excessive on the eeprom writing/rewriting, but you're only storing 1 byte anyway. You could also set a counter in the next two bytes of the eeprom to record how many times the mode byte has been written, and if over "X" many writes then you could jump to the next three bytes. But I can't imagine a flashlight being turned on/off more than a few thousand times in its lifetime.
Thanks for explaining the memory. That's an important part that I want to add later on. I wasn't aware that the EEPROM could be worn out over time.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16