I was messing around and also found out that this works just as well. maybe a little to much but it works fine.
uint8_t volatile edge;
void setup() {
pinMode(RED_LED, OUTPUT);
digitalWrite(RED_LED, LOW);
pinMode(PUSH2, INPUT_PULLUP);
edge = FALLING;
attachInterrupt(PUSH2, func, FALLING);
}
void loop() {
/* Add your loop code here */
}
void func() {
if(edge == FALLING) {
attachInterrupt(PUSH2, func, RISING);
edge = RISING;
} else {
attachInterrupt(PUSH2, func, FALLING);
edge = FALLING;
}
// code to run when interrupt i