Do something - Sleep - Do something code (Sleep with watchdog)

Hi everyone,
I know the topic has been already covered so many times but I still have some doubts.
My basic code does something (blinking an external LED for 5 sec) and then puts to sleep for 80 seconds. The watchdog will wake up Arduino to do the same thing and then sleep again.
The whole code is below:

/*
Sleep with watchdog timer
*/
#include <avr/sleep.h> //this AVR library contains the methods that controls the sleep modes
#include <avr/wdt.h>

const int LEDpin = 7;
// watchdog timer
const int sleeptime = 2; //change to 10800 for 24hr
int counter =0;
// workng duty
unsigned long previousTime = 0;
unsigned long time_interval = 5000;// blinking time duration
unsigned long currentTime;
unsigned long dT;


// watchdog interrupt
ISR (WDT_vect) 
{
   wdt_disable();  // disable watchdog
}  // end of WDT_vect

void MyWDTEnable( const byte interval){
  MCUSR = 0; // clear various "reset" flags
  WDTCSR |= 0b00011000;  // Enter config mode.
  WDTCSR= 0b01000000 | interval;
  wdt_reset();  
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);//Setting up the sleep mode
  noInterrupts ();           // timed sequence follows
  sleep_enable();
  // turn off brown-out enable in software
  MCUCR = bit (BODS) | bit (BODSE);
  MCUCR = bit (BODS); 
  interrupts ();             // guarantees next instruction executed
  sleep_cpu ();  // Go to Sleep and wait for the interrupt
}

void flash(){
  dT=0;
  while (dT<time_interval){
  digitalWrite(LEDpin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LEDpin, LOW);    // turn the LED off by making the voltage LOW
  delay(1000); 
  currentTime = millis();
  dT=currentTime - previousTime;
  }
}

void setup() {
  // initialize digital pin .
  pinMode(LEDpin, OUTPUT);
  digitalWrite(LEDpin, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);
 // disable ADC
  ADCSRA = 0; 
  
}

// the loop function runs over and over again forever
void loop() {
  if (counter < sleeptime){
      MyWDTEnable(0b100001);  // 8 seconds   
     sleep_disable(); // cancel sleep as a precaution
      counter++;
  }
  else{
    delay(100); //delay 
    digitalWrite(LEDpin, HIGH);   // turn the LED on (HIGH is the voltage level)
    previousTime = millis();
    flash();
    counter = 0;
  }

}

The code seems working fine
I noticed that the internal LED is ON during the sleep, so I wonder to save energy if I need to set as LOW all the pins (even those I am not using) or just the pin 13.
Moreover, I add in the setup the

 // disable ADC
  ADCSRA = 0;

because my project does not require any analog readings.
Is that ok?
Would be better to use a library (such as lower power or avr/power) to be sure to power down everything during the sleep?
Thanks

Pins that are set to output but are not connected to anything, do not ever consume power.

aarg:
Pins that are set to output but are not connected to anything, do not ever consume power.

Do I need to declare them as output?
Any way, in the gammon forum,

http://www.gammon.com.au/power

it is mentioned the they consume power even though nothing is connected.
I wonder if I need to declare as output with state low to each one.

AntroxEv:
Do I need to declare them as output?
Any way, in the gammon forum,

Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors

it is mentioned the they consume power even though nothing is connected.
I wonder if I need to declare as output with state low to each one.

I stand corrected. But the main difference there is not input vs. output, but whether it is high or low. The low state does use less power. But, the default state for pins is LOW. So you don't need to set them LOW unless you set them HIGH in your program.

aarg:
I stand corrected. But the main difference there is not input vs. output, but whether it is high or low. The low state does use less power. But, the default state for pins is LOW. So you don't need to set them LOW unless you set them HIGH in your program.

ok, thanks.
I imagine this is not valid for pin 13 which is by default high?

AntroxEv:
ok, thanks.
I imagine this is not valid for pin 13 which is by default high?

It is? I've never observed that. I could be wrong again. I am learning new things today. :slight_smile:

AntroxEv:
ok, thanks.
I imagine this is not valid for pin 13 which is by default high?

Probably whatever the boot loader left it set to, since the boot loader will flash the on board LED at startup, and the LED is on pin 13 on a lot of boards.