#include <BluetoothSerial.h>
BluetoothSerial ESP_BT;
const int pinLed=2;
int incoming;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
ESP_BT.begin("ESP32_LED_CONTROL");
Serial.println("Bluetooth Device is Ready to Pair");
pinMode(pinLed, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (ESP_BT.available()) {
incoming=ESP_BT.read();
Serial.print("Recaived");
if (incoming==49) {
digitalWrite(pinLed, HIGH);
ESP_BT.println("Led turned ON");
}
if (incoming==48) {
digitalWrite(pinLed, LOW);
ESP_BT.println("Led turned OFF");
}
}
}