I'm new here and in the Arduino world. I try to put together a system to cut the power of a LED night light after a preset time. The light is powered by a 5V accu and I would like to avoid to re-charge the accu each morning if the light stays on all night... I purchased an Arduino Nano, a RTC module and a mini OLED display. I would like to kindly ask you for help in putting the system together: programming the Arduino and connecting the module together. The RTC module should open the possibility to completely automate the system (turn power on and off between precise times) and the OLED Display should give the feedback of the current settings. The RTC and OLED modules are just "nice to have", my main goal would be to have an automatic cutting of of the power after a certain time (i.E. 60 min.) after initialization of the system (through a push button, for example). Thank you in advance for your advices!

  • it is much simpler to do a countdown timer then a scheduler with RTC. – Juraj Dec 9 '17 at 5:51
  • Welcome to Arduino SE. Please realize that this is not a free design house, homework-answering service or an on-line technical encyclopedia, copied out to you on demand. People will help you take the next step if your question shows that you've done as much as you possibly could on your own - which your post doesn't. Please revise your question showing your work and findings so far. Or delete the question if Internet searches give you your answer anyway. – user31481 Dec 9 '17 at 9:23

As Juraj said, you don't need an RTC for this. You just have to:

  1. turn the LED on
  2. wait for 60 minutes
  3. turn it off

And do this every time the user presses a push-button.

The code that does this is pretty trivial:

const uint8_t BUTTON_PIN = 2;
const uint8_t LED_PIN = 3;
const uint32_t MINUTE = 60000;
const uint32_t ON_TIME = 60 * MINUTE;

void setup() {
    pinMode(LED_PIN, OUTPUT);

void loop() {
    if (digitalRead(BUTTON_PIN) == LOW) {  // button pressed
        digitalWrite(LED_PIN, HIGH);       // LED on
        delay(ON_TIME);                    // wait
        digitalWrite(LED_PIN, LOW);        // LED off

Now, you can build on top of that whatever “nice to have” functionality you want.

Not the answer you're looking for? Browse other questions tagged or ask your own question.