Skip to content

Commit

Permalink
Use LED_BUILTIN so that it works w/o attaching external LED (esp8266#…
Browse files Browse the repository at this point in the history
…3452)

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

* Use built-in LED

* Clarify text
  • Loading branch information
probonopd authored and igrr committed Sep 21, 2017
1 parent bdf2296 commit ac626ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
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

0 comments on commit ac626ad

Please sign in to comment.