hi, sorry for my bad english,
i test this code from internet
const byte interruptPin = 19;
volatile byte state = LOW;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}
void loop() {
digitalWrite(LED_BUILTIN, state);
}
void blink() {
state = !state;
}
after test it, it seems interesting, i study it, and edit it to become like this:
const byte interruptPin = 19;
volatile byte state = LOW;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin),blinkOn, RISING);
attachInterrupt(digitalPinToInterrupt(interruptPin),blinkOff, FALLING);
}
void loop() {
digitalWrite(LED_BUILTIN, state);
}
void blinkOn() {
state = HIGH;
}
void blinkOff(){
state = LOW;
}
when the arduino turned on, the build-in led is on,
then when first contact, the build-in is turned off,
but when i put the contact, the build-in is not back to on,
it seems 2 interrupt cant be place in same pin, or my code is wrong,
i will appeciate any guide , thanks