Skip to content

Use LED_BUILTIN so that it works w/o attaching external LED #3452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions libraries/Ticker/examples/TickerBasic/TickerBasic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Ticker.h>
Expand All @@ -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
Expand All @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions libraries/Ticker/examples/TickerParameter/TickerParameter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Ticker.h>
Expand All @@ -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)
Expand Down