Small led display with power timer

Hello

I'm making a small project with my girlfriend. It's a very small animation played on a 8*8 led display. I made the program and it's work like a charm except the power part.

I would like to "turn off" the arduino after an amount of the time. The animation will start agin with the reset button. I saw few code example with WatchDog Timer, Enerlib or LowPower library by Rocket Scream but it seems quite too powerfull for what I need.

I've used before for testing and external USB battery who have the ability to turn off automaticly when usb doesn't request power after few seconds. That's perfect for me. If I can do something similiar into my program it will be really cool.

I've tried something with LowPower Library but the led 13 I turn on, doesn't turn off...

void loop() {
  if(elapsedTime < timeforlowerlight){
    lc.shutdown(0,false);
    AnimationFrames();
    //Serial.println(elapsedTime);
  }else if(elapsedTime >= timeforlowerlight){
    for (int i=15; i>0; --i){
      lc.setIntensity(0,i);
      AnimationFrames();
      digitalWrite(led, HIGH);
      decreasok = true;
    }
   lc.shutdown(0,true);
  }else if(elapsedTime > timeforanim){
    lc.shutdown(0,true);
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); 
  }else{ //to be sure screen turn off
  lc.shutdown(0,true);
  LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); 
  }
}

So I was wondering

  1. What is the best way to implement this very simple function of turning off? Wich library?
  2. Are they an arduino better for this kind of stuff? I have a arduino mini with a Funduino shield to have the power part maybe it's better?

Thanks

  1. What is the best way to implement this very simple function of turning off?

A switch that physically disconnects the power source.

Wich library?

I like the Maple Valley library. It has more books than the Black Diamond library.

  1. Are they an arduino better for this kind of stuff?

They are all the same - disconnect power and they stop running. Restore power and they resume working.

Thanks Paul for your answer.

But I would like to turn it off after 10 minutes when I'm not there any more. That's why I'm looking for a timer.

Galouzeau:
I've tried something with LowPower Library but the led 13 I turn on, doesn't turn off...

This is expected behavior. Pins are designed to stay in whatever state you left them in when you go to sleep. So, just turn off all pins (a 'for' loop works great if you have more than one) just before you go to sleep and you should be good.

tylernt:

Galouzeau:
I've tried something with LowPower Library but the led 13 I turn on, doesn't turn off...

This is expected behavior. Pins are designed to stay in whatever state you left them in when you go to sleep. So, just turn off all pins (a 'for' loop works great if you have more than one) just before you go to sleep and you should be good.

Ok thanks. Maybe you now how I can monitor this LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); because the led was only for that.

Thanks

If anyone have an idea.

What's your question? Do you want to be able to see when the Arduino is awake/asleep?

tylernt:
What's your question? Do you want to be able to see when the Arduino is awake/asleep?

Yes excactly. I've turn on board led simply to try to found when the arduino turn aslpeep.

Thanks

I guess I don't understand the problem. If you:

Turn the LED on
Go to sleep
Turn the LED off

then the LED should only be lit when the Arduino is asleep. The instruction following the sleep instruction will execute as soon as the Arduino wakes.

Ok thanks. I thought that the command

LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

Really turn off the arduino and stop output anything expect the one specified (for wake up the device for example).

Thanks