Est ce que ce ne serait pas plus simple un truc du style :
const int buttonPin = 2;
boolean state = 0 ;
void setup()
{
Serial.begin(9600);
attachInterrupt(0, onRelease, FALLING); // Lance onRelease() lorsque on relache le bouton
pinMode(buttonPin, INPUT);
}
void loop()
{
Serial.println(state);
if(state){
for(int i=0; i<100; i++) { // Programme simple pour vérifier l’exécution du programme principal
Serial.println(i);
delay(500);
}
}
}
void onRelease()
{
state = !state ;
}