Last active
October 12, 2023 05:18
-
-
Save lonelybinary/77e673287e770ef7f2d62a334ae236f8 to your computer and use it in GitHub Desktop.
ESP-01S Build-in LED
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Written by Lonely Binary | |
Build-in LED On, Off and Toggle | |
The ESP-01S module features an onboard Blue LED that is intricately connected to GPIO2. | |
When GPIO2 is set to a logic LOW state, it closes the circuit, causing the LED to illuminate. | |
Conversely, when GPIO2 is set to a logic HIGH state, it opens the circuit, resulting in the LED being turned off. | |
ESP-01S Collection: | |
https://lonelybinary.com/collections/ESP-01S | |
*/ | |
#define LED_PIN 2 | |
void setup() { | |
pinMode(LED_PIN, OUTPUT); | |
// LED On for 3 seconds | |
digitalWrite(LED_PIN, LOW); | |
delay(3000); | |
// LED Off | |
digitalWrite(LED_PIN, HIGH); | |
} | |
void loop() { | |
// Toggle the LED | |
digitalWrite(LED_PIN, !digitalRead(LED_PIN)); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment