// Define the GPIO pins for your three LEDs
// You can change these to any suitable digital GPIO pin on your ESP32 board.
// Avoid pins used for specific functions like TX/RX (GPIO1, GPIO3) or strapping pins during boot.
const int ledPin1 = 16; // Example: Connecting the first LED to ESP32's GPIO 16
const int ledPin2 = 17; // Example: Connecting the second LED to ESP32's GPIO 17
const int ledPin3 = 4; // Example: Connecting the third LED to ESP32's GPIO 4
// Define the blink interval (in milliseconds)
// This controls how long each state lasts before switching.
// 500 milliseconds = 0.5 seconds
const long blinkInterval = 500;
void setup() {
// Initialize the serial communication for debugging (optional but recommended)
Serial.begin(115200);
Serial.println("ESP32 Three LED Blink Program Started!");
// Set all LED pins as OUTPUTs
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
// Initial state: Ensure all LEDs are off when the program starts.
digitalWrite(ledPin1, LOW); // LOW means 0V (LED off)
digitalWrite(ledPin2, LOW); // LOW means 0V (LED off)
digitalWrite(ledPin3, LOW); // LOW means 0V (LED off)
}
void loop() {
// --- Pattern 1: LED1 ON, others OFF ---
Serial.println("Pattern 1: LED1 ON");
digitalWrite(ledPin1, HIGH); // LED1 ON
digitalWrite(ledPin2, LOW); // LED2 OFF
digitalWrite(ledPin3, LOW); // LED3 OFF
delay(blinkInterval);
// --- Pattern 2: LED2 ON, others OFF ---
Serial.println("Pattern 2: LED2 ON");
digitalWrite(ledPin1, LOW); // LED1 OFF
digitalWrite(ledPin2, HIGH); // LED2 ON
digitalWrite(ledPin3, LOW); // LED3 OFF
delay(blinkInterval);
// --- Pattern 3: LED3 ON, others OFF ---
Serial.println("Pattern 3: LED3 ON");
digitalWrite(ledPin1, LOW); // LED1 OFF
digitalWrite(ledPin2, LOW); // LED2 OFF
digitalWrite(ledPin3, HIGH); // LED3 ON
delay(blinkInterval);
// You can add more complex patterns here if you wish!
// For example, having all LEDs on, or a chasing light effect.
// The loop() function will repeat these patterns indefinitely.
}