hi!
imo example program attachinterrupt() suboptimal (if not wrong @ all). brushed little bit:
maybe 1 less confusing :-)
gregor
imo example program attachinterrupt() suboptimal (if not wrong @ all). brushed little bit:
code: [select]
int interruptpin = 2;
int ledpin = 13;
volatile int state = low;
void setup() {
pinmode(ledpin, output);
attachinterrupt(digitalpintointerrupt(interruptpin), blink, change);
}
void loop() {
digitalwrite(ledpin, state);
}
void blink() {
state = !state;
}
maybe 1 less confusing :-)
gregor
is original example not wrong? came here looking clarification, original code reads:
it uses same pin, 13, both drive led , attach interrupt. isn't error?
unless i'm mistaken, code correct while original indeed wrong.
code: [select]
int pin = 13;
volatile int state = low;
void setup() {
pinmode(pin, output);
attachinterrupt(digitalpintointerrupt(pin), blink, change);
}
void loop() {
digitalwrite(pin, state);
}
void blink() {
state = !state;
}
it uses same pin, 13, both drive led , attach interrupt. isn't error?
unless i'm mistaken, code correct while original indeed wrong.
Arduino Forum > Development > Suggestions for the Arduino Project > Example for attachInterrupt()
arduino
Comments
Post a Comment