Hi all, I'm new to Arduino. Is it possible to programme it to turn on after X hours, manually turn off by push switch and it'll automatically turn on after X hours again? I'm willing to learn, looking for some guidance!
yes, of course it is. Look at the Blink Without Delay example in the IDE (File->examples->02.Digital->BlinkWithoutDelay) as it will show you how to measure elapsed time without blocking the rest of your code which will be needing to check the state of your switch.
Define "turn on", and "turn off". Do you mean shut down completely, or just do nothing while consuming power?
blh64:
yes, of course it is. Look at the Blink Without Delay example in the IDE (File->examples->02.Digital->BlinkWithoutDelay) as it will show you how to measure elapsed time without blocking the rest of your code which will be needing to check the state of your switch.
Thank you so much! I'm actually new to electronics in general, taking my time to learn step by step (:
aarg:
Define "turn on", and "turn off". Do you mean shut down completely, or just do nothing while consuming power?
Say it turns on a LED. I would prefer it to shut down completely to conserve energy, and it reboots itself after X hours. Is that possible?
redgrandline:
Say it turns on a LED. I would prefer it to shut down completely to conserve energy, and it reboots itself after X hours. Is that possible?
No, not without external hardware.
But you can sleep for periods of time (which uses very little power) and wake up every so often to check time passing.
How accurate must the X hours be? That is key as to if you will require a real time clock module or not.
redgrandline:
Thank you so much! I'm actually new to electronics in general, taking my time to learn step by step (:Say it turns on a LED. I would prefer it to shut down completely to conserve energy, and it reboots itself after X hours. Is that possible?
No its not.
If a board is shut down 'completly' then there is no available power for anything to keep time and know when to wake up again.
It depends on the Arduino in use, but most can be put into a deep sleep where they are not shut down 'completly' but consume a small amount of power, say 10uA or less, which allows for the processor (or some external device) to keep time.
For such deep sleep applications a lot of most bought Arduinos are fairly useless, they have lots of components that consume power even when the processor itself is in deep sleep.
The solution to this is to build a 'bare bones' Arduino and these can be persuaded to wake up every 'few hours' with no additional components. However the planned shutdown of 2hours might be 1.8 hours or 2.2 hours but often this is not a problem.
If you want greater timing accuracy then you can add a real time clock (RTC) module and use this to wakeup the Arduino. The RTC normally have a very low sleep current.