|
2 | 2 | ESP8266 Blink by Simon Peter
|
3 | 3 | Blink the blue LED on the ESP-01 module
|
4 | 4 | This example code is in the public domain
|
| 5 | + |
| 6 | + The blue LED on the ESP-01 module is connected to GPIO1 |
| 7 | + (which is also the TXD pin; so we cannot use Serial.print() at the same time) |
| 8 | + |
| 9 | + Note that this sketch uses BUILTIN_LED to find the pin with the internal LED |
5 | 10 | */
|
6 | 11 |
|
7 |
| -const int ledPin = 1; // The blue LED on the ESP-01 module is connected to GPIO1 |
8 |
| - // (which is also the TXD pin; so we cannot use |
9 |
| - // Serial.print() at the same time |
10 |
| - |
11 | 12 | void setup() {
|
12 |
| - pinMode(ledPin, OUTPUT); // Initialize the ledPin as an output |
| 13 | + pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output |
13 | 14 | }
|
14 | 15 |
|
15 | 16 | // the loop function runs over and over again forever
|
16 | 17 | void loop() {
|
17 |
| - digitalWrite(ledPin, LOW); // turn the LED on (Note that LOW is the voltage level |
18 |
| - // but actually the LED is on; this is because |
19 |
| - // it is acive low on the ESP-01) |
20 |
| - delay(1000); // Wait for a second |
21 |
| - digitalWrite(ledPin, HIGH); // Turn the LED off by making the voltage HIGH |
22 |
| - delay(2000); // Wait for two seconds (to demonstrate the active low LED) |
| 18 | + digitalWrite(BUILTIN_LED, LOW); // Turn the LED on (Note that LOW is the voltage level |
| 19 | + // but actually the LED is on; this is because |
| 20 | + // it is acive low on the ESP-01) |
| 21 | + delay(1000); // Wait for a second |
| 22 | + digitalWrite(BUILTIN_LED, HIGH); // Turn the LED off by making the voltage HIGH |
| 23 | + delay(2000); // Wait for two seconds (to demonstrate the active low LED) |
23 | 24 | }
|
0 commit comments