diff --git a/hardware/esp8266com/esp8266/libraries/esp8266/examples/Blink/Blink.ino b/hardware/esp8266com/esp8266/libraries/esp8266/examples/Blink/Blink.ino new file mode 100644 index 0000000000..578f368864 --- /dev/null +++ b/hardware/esp8266com/esp8266/libraries/esp8266/examples/Blink/Blink.ino @@ -0,0 +1,24 @@ +/* + ESP8266 Blink by Simon Peter + Blink the blue LED on the ESP-01 module + This example code is in the public domain + + The blue LED on the ESP-01 module is connected to GPIO1 + (which is also the TXD pin; so we cannot use Serial.print() at the same time) + + Note that this sketch uses BUILTIN_LED to find the pin with the internal LED +*/ + +void setup() { + pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output +} + +// the loop function runs over and over again forever +void loop() { + digitalWrite(BUILTIN_LED, LOW); // Turn the LED on (Note that LOW is the voltage level + // but actually the LED is on; this is because + // it is acive low on the ESP-01) + delay(1000); // Wait for a second + digitalWrite(BUILTIN_LED, HIGH); // Turn the LED off by making the voltage HIGH + delay(2000); // Wait for two seconds (to demonstrate the active low LED) +} diff --git a/hardware/esp8266com/esp8266/libraries/esp8266/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino b/hardware/esp8266com/esp8266/libraries/esp8266/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino new file mode 100644 index 0000000000..740211d6d1 --- /dev/null +++ b/hardware/esp8266com/esp8266/libraries/esp8266/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino @@ -0,0 +1,33 @@ +/* + ESP8266 BlinkWithoutDelay by Simon Peter + Blink the blue LED on the ESP-01 module + Based on the Arduino Blink without Delay example + This example code is in the public domain + + The blue LED on the ESP-01 module is connected to GPIO1 + (which is also the TXD pin; so we cannot use Serial.print() at the same time) + + Note that this sketch uses BUILTIN_LED to find the pin with the internal LED +*/ + +int ledState = LOW; + +unsigned long previousMillis = 0; +const long interval = 1000; + +void setup() { + pinMode(BUILTIN_LED, OUTPUT); +} + +void loop() +{ + unsigned long currentMillis = millis(); + if(currentMillis - previousMillis >= interval) { + previousMillis = currentMillis; + if (ledState == LOW) + ledState = HIGH; // Note that this switches the LED *off* + else + ledState = LOW; // Note that this switches the LED *on* + digitalWrite(BUILTIN_LED, ledState); + } +}