#include "BluetoothSerial.h" // Include BluetoothSerial library for real ESP32 (not used in Wokwi)
const int ledPin = 2; // LED connected to GPIO 2
void setup() {
// Initialize the LED pin
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // Start with LED off
// Begin Serial communication for Wokwi simulation
Serial.begin(115200);
Serial.println("Wokwi Simulation: Send '1' to turn ON LED, '0' to turn OFF");
}
void loop() {
// Check if there's data available from Serial Monitor
if (Serial.available()) {
char incomingChar = Serial.read();
// Print received data to Serial Monitor
Serial.print("Received: ");
Serial.println(incomingChar);
// Control the LED based on the input
if (incomingChar == '1') {
digitalWrite(ledPin, HIGH); // Turn the LED on
Serial.println("LED is ON");
} else if (incomingChar == '0') {
digitalWrite(ledPin, LOW); // Turn the LED off
Serial.println("LED is OFF");
} else {
Serial.println("Invalid Command. Send '1' to turn ON, '0' to turn OFF.");
}
}
}