I am experimenting with PinInterrups on Duemilanove 328 using simple code.
It appears that the Interrupt service routine is triggered once on board startup.
What I want to do:
- Startup --> pin13 LED Off
- Ground pin2 (Interrupt 0) --> Toggle pin13 LED
int pin = 13;
volatile int state = LOW;
attachInterrupt(0, blink, FALLING);
state = !state;
Expected: After startup LED stays off
What happens: After startup LED turn on
How to fix: Change volatile int state = LOW;
to volatile int state = HIGH;
Can anyone shed some light on this?