diff --git a/libraries/Ticker/examples/TickerBasic/TickerBasic.ino b/libraries/Ticker/examples/TickerBasic/TickerBasic.ino index a387b554b71..8de5a1282ad 100644 --- a/libraries/Ticker/examples/TickerBasic/TickerBasic.ino +++ b/libraries/Ticker/examples/TickerBasic/TickerBasic.ino @@ -23,26 +23,26 @@ Ticker flipper; int count = 0; void flip() { - int state = digitalRead(LED_BUILTIN); // get the current state of GPIO1 pin - digitalWrite(LED_BUILTIN, !state); // set pin to the opposite state - - ++count; - // when the counter reaches a certain value, start blinking like crazy - if (count == 20) { - flipper.attach(0.1, flip); - } - // when the counter reaches yet another value, stop blinking - else if (count == 120) { - flipper.detach(); - } + int state = digitalRead(LED_BUILTIN); // get the current state of GPIO1 pin + digitalWrite(LED_BUILTIN, !state); // set pin to the opposite state + + ++count; + // when the counter reaches a certain value, start blinking like crazy + if (count == 20) { + flipper.attach(0.1, flip); + } + // when the counter reaches yet another value, stop blinking + else if (count == 120) { + flipper.detach(); + } } void setup() { - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, LOW); + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); - // flip the pin every 0.3s - flipper.attach(0.3, flip); + // flip the pin every 0.3s + flipper.attach(0.3, flip); } void loop() { diff --git a/libraries/Ticker/examples/TickerParameter/TickerParameter.ino b/libraries/Ticker/examples/TickerParameter/TickerParameter.ino index a6c7d9d2348..ceb79e32f54 100644 --- a/libraries/Ticker/examples/TickerParameter/TickerParameter.ino +++ b/libraries/Ticker/examples/TickerParameter/TickerParameter.ino @@ -17,26 +17,37 @@ #define LED_BUILTIN 13 #endif -Ticker tickerSetHigh; Ticker tickerSetLow; +Ticker tickerSetHigh; +Ticker tickerSetChar; + +void setPinLow() { + digitalWrite(LED_BUILTIN, 0); +} + +void setPinHigh() { + digitalWrite(LED_BUILTIN, 1); +} void setPin(int state) { - digitalWrite(LED_BUILTIN, state); + digitalWrite(LED_BUILTIN, state); } void setPinChar(char state) { - digitalWrite(LED_BUILTIN, state); + digitalWrite(LED_BUILTIN, state); } void setup() { - pinMode(LED_BUILTIN, OUTPUT); + pinMode(LED_BUILTIN, OUTPUT); - // every 25 ms, call setPin(0) - tickerSetLow.attach_ms(25, setPin, 0); + // every 25 ms, call setPinLow() + tickerSetLow.attach_ms(25, setPinLow); - // every 26 ms, call setPinChar(1) - tickerSetHigh.attach_ms(26, setPinChar, (char)1); + // every 26 ms, call setPinHigh() + tickerSetHigh.attach_ms(26, setPinHigh); + // every 54 ms, call setPinChar(1) + tickerSetChar.attach_ms(26, setPinChar, (char)1); } void loop() {