File tree 2 files changed +8
-10
lines changed
libraries/Ticker/examples
2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 9
9
There are two variants of the attach function: attach and attach_ms.
10
10
The first one takes period in seconds, the second one in milliseconds.
11
11
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.
14
13
*/
15
14
16
15
#include < Ticker.h>
@@ -21,8 +20,8 @@ int count = 0;
21
20
22
21
void flip ()
23
22
{
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
26
25
27
26
++count;
28
27
// when the counter reaches a certain value, start blinking like crazy
@@ -38,8 +37,8 @@ void flip()
38
37
}
39
38
40
39
void setup () {
41
- pinMode (1 , OUTPUT);
42
- digitalWrite (1 , LOW);
40
+ pinMode (LED_BUILTIN , OUTPUT);
41
+ digitalWrite (LED_BUILTIN , LOW);
43
42
44
43
// flip the pin every 0.3s
45
44
flipper.attach (0.3 , flip);
Original file line number Diff line number Diff line change 8
8
This sample runs two tickers that both call one callback function,
9
9
but with different arguments.
10
10
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.
13
12
*/
14
13
15
14
#include < Ticker.h>
@@ -18,11 +17,11 @@ Ticker tickerSetHigh;
18
17
Ticker tickerSetLow;
19
18
20
19
void setPin (int state) {
21
- digitalWrite (1 , state);
20
+ digitalWrite (LED_BUILTIN , state);
22
21
}
23
22
24
23
void setup () {
25
- pinMode (1 , OUTPUT);
24
+ pinMode (LED_BUILTIN , OUTPUT);
26
25
digitalWrite (1 , LOW);
27
26
28
27
// every 25 ms, call setPin(0)
You can’t perform that action at this time.
0 commit comments