File tree 2 files changed +57
-0
lines changed
hardware/esp8266com/esp8266/libraries/esp8266/examples
2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ ESP8266 Blink by Simon Peter
3
+ Blink the blue LED on the ESP-01 module
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
10
+ */
11
+
12
+ void setup () {
13
+ pinMode (BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output
14
+ }
15
+
16
+ // the loop function runs over and over again forever
17
+ void loop () {
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)
24
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ ESP8266 BlinkWithoutDelay by Simon Peter
3
+ Blink the blue LED on the ESP-01 module
4
+ Based on the Arduino Blink without Delay example
5
+ This example code is in the public domain
6
+
7
+ The blue LED on the ESP-01 module is connected to GPIO1
8
+ (which is also the TXD pin; so we cannot use Serial.print() at the same time)
9
+
10
+ Note that this sketch uses BUILTIN_LED to find the pin with the internal LED
11
+ */
12
+
13
+ int ledState = LOW;
14
+
15
+ unsigned long previousMillis = 0 ;
16
+ const long interval = 1000 ;
17
+
18
+ void setup () {
19
+ pinMode (BUILTIN_LED, OUTPUT);
20
+ }
21
+
22
+ void loop ()
23
+ {
24
+ unsigned long currentMillis = millis ();
25
+ if (currentMillis - previousMillis >= interval) {
26
+ previousMillis = currentMillis;
27
+ if (ledState == LOW)
28
+ ledState = HIGH; // Note that this switches the LED *off*
29
+ else
30
+ ledState = LOW; // Note that this switches the LED *on*
31
+ digitalWrite (BUILTIN_LED, ledState);
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments