#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

#define RedLed 22
#define GreenLed 23

String recv = "";

BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200);
  pinMode(RedLed, OUTPUT);
  pinMode(GreenLed, OUTPUT);

  SerialBT.begin("ESP32_LED_Control"); //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");
}

void loop()
{
  while (SerialBT.available()) // Read until the bluetooth client is sending.
  {
    char string = SerialBT.read();
    recv = recv + string;
    delay(1);
    
  }
  
  if (recv == "A")
  {
    digitalWrite(RedLed, HIGH);
  }
  if (recv == "a")
  {
    digitalWrite(RedLed,LOW);
  }
  if (recv == "B")
  {
    digitalWrite(GreenLed, HIGH);
  }
  if (recv == "b")
  {
    digitalWrite(GreenLed,LOW);
  }
  if (recv == "AB")
  {
    digitalWrite(RedLed, HIGH);
    digitalWrite(GreenLed, HIGH);    
  }
  if (recv == "ab")
  {
    digitalWrite(RedLed, LOW);
    digitalWrite(GreenLed, LOW);   
  }
  recv = ""; // clearing the string.
}
$abcdeabcde151015202530fghijfghij
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
led1:A
led1:C
led2:A
led2:C
r1:1
r1:2
r2:1
r2:2