Skip to content
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

attachInterrupt, a big hole in documentation and no example #1152

Open
PM04290 opened this issue Oct 19, 2024 · 1 comment
Open

attachInterrupt, a big hole in documentation and no example #1152

PM04290 opened this issue Oct 19, 2024 · 1 comment

Comments

@PM04290
Copy link

PM04290 commented Oct 19, 2024

For several days I have been struggling with an ATTiny3216 to understand why in standby, when I use attachInterrupt I have 200µA of consumption when I should only have 2µA.
In fact I was using the function like this: attachInterrupt(PIN_PA5, myFunc, FALLING)
while it should be used like this: attachInterrupt(digitalPinToInterrupt(PIN_PA5), myFunc, FALLING)
the first parameter is named "pin", for me it seemed logical.
the documentation should be improved and an example put

@hmeijdam
Copy link

I am not sure that Attachinterrupt is MegatinyCore specific. It seems a generic Arduino function that has it's own reference documentation overhere

It has an example, including the mentioned "digitalPinToInterrupt"

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;
}

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