Skip to content

Ticker fix solving #6155 #7664

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

Merged
merged 8 commits into from
Feb 6, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions libraries/Ticker/examples/Arguments/Arguments.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
Ticker tickerSetHigh;
Ticker tickerSetLow;

void setPin(int state) {
digitalWrite(LED_PIN, state);
// Argument to callback must always be passed a reference
void setPin(int *state) {
digitalWrite(LED_PIN, *state);
}

void setup() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(1, LOW);

// every 25 ms, call setPin(0)
tickerSetLow.attach_ms(25, setPin, 0);
int state = 0;
tickerSetLow.attach_ms(25, setPin, &state);

// every 26 ms, call setPin(1)
tickerSetHigh.attach_ms(26, setPin, 1);
state = 1;
tickerSetHigh.attach_ms(26, setPin, &state);
}

void loop() {
Expand Down