#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! please run `make menuconfig` to and enabled it
#endif
BluetoothSerial SerialBT;
const int ledPin = 23;
String message = "";
char incomingChar;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
SerialBT.begin("ESP32_SUV");
Serial.println("The device started, now you can pair it with blueetooth!");
}
void loop() {
if (SerialBT.available()){
char incomingChar = SerialBT.read();
if (incomingChar != '\n'){
message += String(incomingChar);
}
else{
message = "";
}
Serial.write(incomingChar);
}
if (message =="XYZ") {
digitalWrite(ledPin, HIGH);
}
else if (message =="ABC") {
digitalWrite(ledPin, LOW);
}
delay(20);
}