File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
hardware/esp8266com/esp8266/libraries/esp8266/examples/BlinkWithoutDelay Expand file tree Collapse file tree 1 file changed +33
-0
lines changed 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
+
8
+ const int ledPin = 1 ; // The blue LED on the ESP-01 module is connected to GPIO1
9
+ // (which is also the TXD pin; so we cannot use
10
+ // Serial.print() at the same time
11
+
12
+ int ledState = LOW;
13
+
14
+ unsigned long previousMillis = 0 ;
15
+ const long interval = 1000 ;
16
+
17
+ void setup () {
18
+ pinMode (ledPin, OUTPUT);
19
+ }
20
+
21
+ void loop ()
22
+ {
23
+ unsigned long currentMillis = millis ();
24
+ if (currentMillis - previousMillis >= interval) {
25
+ previousMillis = currentMillis;
26
+ if (ledState == LOW)
27
+ ledState = HIGH; // Note that this switches the LED *off*
28
+ else
29
+ ledState = LOW; // Note that this switches the LED *on*
30
+ digitalWrite (ledPin, ledState);
31
+ }
32
+ }
33
+
You can’t perform that action at this time.
0 commit comments