From ac626ad9f8b398ae4cd56b9325541ba3a99fffd7 Mon Sep 17 00:00:00 2001 From: probonopd Date: Thu, 21 Sep 2017 11:22:27 +0200 Subject: [PATCH] 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 --- libraries/Ticker/examples/TickerBasic/TickerBasic.ino | 11 +++++------ .../examples/TickerParameter/TickerParameter.ino | 7 +++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libraries/Ticker/examples/TickerBasic/TickerBasic.ino b/libraries/Ticker/examples/TickerBasic/TickerBasic.ino index 772b5b74c..4a128e8b8 100644 --- a/libraries/Ticker/examples/TickerBasic/TickerBasic.ino +++ b/libraries/Ticker/examples/TickerBasic/TickerBasic.ino @@ -9,8 +9,7 @@ There are two variants of the attach function: attach and attach_ms. The first one takes period in seconds, the second one in milliseconds. - An LED connected to GPIO1 will be blinking. Use a built-in LED on ESP-01 - or connect an external one to TXD on other boards. + The built-in LED will be blinking. */ #include @@ -21,8 +20,8 @@ int count = 0; void flip() { - int state = digitalRead(1); // get the current state of GPIO1 pin - digitalWrite(1, !state); // set pin to the opposite state + 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 @@ -38,8 +37,8 @@ void flip() } void setup() { - pinMode(1, OUTPUT); - digitalWrite(1, LOW); + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LOW); // flip the pin every 0.3s flipper.attach(0.3, flip); diff --git a/libraries/Ticker/examples/TickerParameter/TickerParameter.ino b/libraries/Ticker/examples/TickerParameter/TickerParameter.ino index 80eec5e67..705735339 100644 --- a/libraries/Ticker/examples/TickerParameter/TickerParameter.ino +++ b/libraries/Ticker/examples/TickerParameter/TickerParameter.ino @@ -8,8 +8,7 @@ This sample runs two tickers that both call one callback function, but with different arguments. - An LED connected to GPIO1 will be pulsing. Use a built-in LED on ESP-01 - or connect an external one to TXD on other boards. + The built-in LED will be pulsing. */ #include @@ -18,11 +17,11 @@ Ticker tickerSetHigh; Ticker tickerSetLow; void setPin(int state) { - digitalWrite(1, state); + digitalWrite(LED_BUILTIN, state); } void setup() { - pinMode(1, OUTPUT); + pinMode(LED_BUILTIN, OUTPUT); digitalWrite(1, LOW); // every 25 ms, call setPin(0)