DanielBnl:
The resetting has to happen automatically after I press the pushbutton counter 16 times. I forgot to mention that I'm using an Multi Function Shield for this as this is required.
this would be the entire (un-tested) code using that library:
#include <avr/wdt.h>
#include "MultiPress.h"
#define LEDPIN 13
#define BUTTON 3
void buttonActions(const int value);
SimplePress pushButtonSwitches[] = {
{BUTTON, 300, buttonActions},
};
void setup()
{
MCUSR = 0;
WDTCSR |= _BV(WDCE) | _BV(WDE);
WDTCSR = 0;
Serial.begin(115200);
pinMode(LEDPIN, OUTPUT);
Serial.println(SimplePress::getCount());
SimplePress::beginAll();
SimplePress::setDebounceAll(50);
}
void loop()
{
SimplePress::update();
}
void buttonActions(const int value) // example of registering Multi-Presses
{
Serial.print(F("Button B:\t"));
Serial.println(value);
switch (value)
{
case 16:
Serial.println(F("RESETTING"));
wdt_enable(WDTO_1S); while (1) {}
break;
}
}