Thank you for the suggestions.
I've tried to add a pull-down resistor (in option 2):
But it has no effect. As soon as I give power, the board goes on. Another strange thing is that, after 10 blinks I set digital pin2 LOW, but it has no effect (the board remains on).
void setup() {
pinMode(2, OUTPUT);
digitalWrite(2, HIGH); // keep power on
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
// do something
for (int i=0;i<10;i++) // blink LED ten times
{
digitalWrite(13, HIGH); // set the LED on
delay(3000);
digitalWrite(13, LOW); // set the LED off
delay(2000);
}
digitalWrite(2, LOW); // force power off <<<<<<<<<<<<<<
}
I also tried connecting the pulldown resostor from digital pin 2 to ground...same behaviour...
I'll try to add a cap, but I really don't understand why, setting pin2 LOW, it does not cut power...