About Arduino interrupt Pin

Hi,
The code below works well when const byte interruptPin = 2; the LED ON/OFF by button;

the LED keep ON when changed into const byte interruptPin = 3; .
why?
Thanks
Adam

  const byte ledPin = 13;
  const byte interruptPin = 3; 

  volatile byte state = LOW;

  void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
  }

  void loop() {
  digitalWrite(ledPin, state);
  }

  void blink() {
  state = !state;
  }

Is this an UNO ?

Did you move the wire from pin 2 to pin 3 ?

1 Like

Write the value of

to the Serial Monitor. Each controller can have different interrupt pins.

1 Like

Thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.