#include <avr/wdt.h>
volatile bool pushed = 0;
void button(){
pushed = 1;
}
void reset(){
while(true)
{
wdt_enable(WDTO_15MS);
for(;;) {};
}
}
void disableReset()
{
MCUSR = 0 ;
wdt_disable() ;
}
void setup() {
pinMode(2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2),button,FALLING);
pinMode(13, OUTPUT);
Serial.begin(115200);
}
void loop() {
delay(3000);
Serial.println("This will be printed");
if(pushed == 0) {reset();}//Arduino will allways reset
if(pushed == 1) {pushed = 0;} //Unless button is pushed
Serial.println("This is printed if button is pushed");
}