Skip to content

attachInterrupt problem #8711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Omar-alSuntawi opened this issue Mar 27, 2019 · 1 comment
Closed

attachInterrupt problem #8711

Omar-alSuntawi opened this issue Mar 27, 2019 · 1 comment

Comments

@Omar-alSuntawi
Copy link

Omar-alSuntawi commented Mar 27, 2019

This code does not work correctly !

const byte ledPin = 13;
const byte interruptPin = 2;
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;
}

which is on the Arduino Reference https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/

It seems to accidentally read random values.

@per1234
Copy link
Collaborator

per1234 commented Mar 27, 2019

Moved to arduino/reference-en#575

@per1234 per1234 closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants