Skip to content

Instantly share code, notes, and snippets.

@lonelybinary
Last active October 12, 2023 05:18
Show Gist options
  • Save lonelybinary/77e673287e770ef7f2d62a334ae236f8 to your computer and use it in GitHub Desktop.
Save lonelybinary/77e673287e770ef7f2d62a334ae236f8 to your computer and use it in GitHub Desktop.
ESP-01S Build-in LED
/*
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