Skip to content

Commit ac626ad

Browse files
probonopdigrr
authored andcommitted
Use LED_BUILTIN so that it works w/o attaching external LED (#3452)
* Use LED_BUILTIN so that it works w/o attaching external LED * Use built-in LED * Clarify text
1 parent bdf2296 commit ac626ad

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

libraries/Ticker/examples/TickerBasic/TickerBasic.ino

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
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

2221
void 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

4039
void 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);

libraries/Ticker/examples/TickerParameter/TickerParameter.ino

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
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;
1817
Ticker tickerSetLow;
1918

2019
void setPin(int state) {
21-
digitalWrite(1, state);
20+
digitalWrite(LED_BUILTIN, state);
2221
}
2322

2423
void setup() {
25-
pinMode(1, OUTPUT);
24+
pinMode(LED_BUILTIN, OUTPUT);
2625
digitalWrite(1, LOW);
2726

2827
// every 25 ms, call setPin(0)

0 commit comments

Comments
 (0)