I am considering a small lighting dimming project although at night the power to the whole circuit will be cut off. Is there a way to store values (specifically PWM levels for dimming) and have the lights return to the specified level of dimming automatically when the circuit powers on in the morning? any info on this tutorials etc. would be appreciated.
Use the EEPROM.
Pieter
Use the EEPROM.
Be aware that EEPROM has limited erase/write cycles, so only write values a few seconds after they have last changed.
What are you dimming that will cause total power to be lost ?
It would seem that only the power to the lamp would be cut off ?
Is there a way to have the MCU detect a drop in voltage (say across a large power cap/5V supercap) giving it enough time to write to EEPROM if say Voltage <2.5V and then goes to sleep till voltage >4.5 again for example?
Found this:
Low Voltage Detector IC
So it basically Outputs low when Vsupply <3V and high when Vsupply>3V.
An external interrupt pin could be used to detect the FALL.
For example, saving to EEPROM and sleeping on a FALLING edge of the INT pin.
Any clarify this as a good idea or is there a "better" MCU only option?
How about using a rechargeable battery pack?
When the power is on charge the batteries and run the processor - when the power goes off disable any outputs or anything that takes much power and have a single LED to indicate that the power is off but your processor is fine
Can't remember if an Arduino has a "sleep" function - but it does not take much battery to keep the standard processor running for a long time
Thanks for the replys. For a better understanding this is for display lighting. The whole lighting circuit is usually on a timer so power to the actual circuit which powers the arduino will be cut off say 6pm and on again 8am. I will look into EEPROM and battery backup just wondering what would be the best option
pwatsoon:
Thanks for the replys. For a better understanding this is for display lighting. The whole lighting circuit is usually on a timer so power to the actual circuit which powers the arduino will be cut off say 6pm and on again 8am. I will look into EEPROM and battery backup just wondering what would be the best option
So put the Arduino before the time clock.
This is impractical as will have multiple arduinos controlling seperate displays
pwatsoon:
This is impractical as will have multiple arduinos controlling seperate displays
Is their any other vital information that you are withholding or can we all stop wasting our time now?
EEPROM is the way to go to store values that have to survive power down. That's what it's meant for, plain and simple.
To save your cycles, use EEPROM.update() as that will only write the data if it's different from what's in EEPROM already. It has a limit on write cycles, not on read cycles.