Skip to content

Commit ac5c763

Browse files
probonopdigrr
authored andcommitted
ESP8266 BlinkWithoutDelay
1 parent 84b14ca commit ac5c763

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+

0 commit comments

Comments
 (0)