Thank you all! This fixed the problem
User interrupt 0 supports arduino pin 2, and interrupt 1 supports arduino pin 3.
So change your attachment code
from : attachInterrupt(buttonPin,flash,LOW);
to : attachInterrupt(0,flash,LOW); // if a low is seen on pin 2, generate an interrupt to flash
and about this
in the ISR flash, every time you get an interrupt you change the state of buttonState which is redundant with the state of the ledPin but shows whether the LED is on or not?
Yes, I knew that but that was irrelevant to the problem, remember this is just a simple example to try to get working the external interrupts.
How is your buttonPin wired? Normally open, and pressing it closes to ground to bring the interrupt input Low?
Then you will need this line uncommented to turn on the internal pullup.
// digitalWrite(buttonPin, HIGH);
I had a pull-up circuit (to 5V) interface between the button and the MCU.
You may need some debounce for the buttonPin -every time it is pressed, it will look like 01010101000000 before finally settling, and then similar on release, so if you just press & release quick, you don't really know what you're gonna end up with.
Yes, I was aware of this but I knew this was not the problem. I tried the same example but without toggling the variable every time, so if that would have happened then the LED would just have stayed on. In fact, I can now see that it has a lot of bouncing! But I know how to fix that quickly
Anyway, many thanks I really appreciate your help!