JSFiddle - React, Tailwind, and code Playground

by unknown601

HTML

#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

BluetoothSerial SerialBT;

char appData;
String inData = "";
const int zap = 4;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("Apples"); //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");
  pinMode(zap, OUTPUT);
}

void loop() {
  appData = SerialBT.read();
  inData = String(appData); 
  Serial.write(appData);
  while ( inData == "a")
  {
    digitalWrite(zap, LOW);
  }
  while ( inData == "b")
  {
    digitalWrite(zap, HIGH);
    delay(500);
    digitalWrite(zap, LOW);
    delay(500);
  }
  delay(20);
}