File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
libraries/Ticker/examples Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 99 There are two variants of the attach function: attach and attach_ms.
1010 The first one takes period in seconds, the second one in milliseconds.
1111
12- An LED connected to GPIO1 will be blinking. Use a built-in LED on ESP-01
13- or connect an external one to TXD on other boards.
12+ The built-in LED will be blinking.
1413*/
1514
1615#include < Ticker.h>
@@ -21,8 +20,8 @@ int count = 0;
2120
2221void flip ()
2322{
24- int state = digitalRead (1 ); // get the current state of GPIO1 pin
25- digitalWrite (1 , !state); // set pin to the opposite state
23+ int state = digitalRead (LED_BUILTIN ); // get the current state of GPIO1 pin
24+ digitalWrite (LED_BUILTIN , !state); // set pin to the opposite state
2625
2726 ++count;
2827 // when the counter reaches a certain value, start blinking like crazy
@@ -38,8 +37,8 @@ void flip()
3837}
3938
4039void setup () {
41- pinMode (1 , OUTPUT);
42- digitalWrite (1 , LOW);
40+ pinMode (LED_BUILTIN , OUTPUT);
41+ digitalWrite (LED_BUILTIN , LOW);
4342
4443 // flip the pin every 0.3s
4544 flipper.attach (0.3 , flip);
Original file line number Diff line number Diff line change 88 This sample runs two tickers that both call one callback function,
99 but with different arguments.
1010
11- An LED connected to GPIO1 will be pulsing. Use a built-in LED on ESP-01
12- or connect an external one to TXD on other boards.
11+ The built-in LED will be pulsing.
1312*/
1413
1514#include < Ticker.h>
@@ -18,11 +17,11 @@ Ticker tickerSetHigh;
1817Ticker tickerSetLow;
1918
2019void setPin (int state) {
21- digitalWrite (1 , state);
20+ digitalWrite (LED_BUILTIN , state);
2221}
2322
2423void setup () {
25- pinMode (1 , OUTPUT);
24+ pinMode (LED_BUILTIN , OUTPUT);
2625 digitalWrite (1 , LOW);
2726
2827 // every 25 ms, call setPin(0)
You can’t perform that action at this time.
0 commit comments