2023-02-02 16:39:30 +01:00

39 lines
822 B
C++

#include "BluetoothSerial.h"
#include <M5StickC.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;
void setup() {
M5.begin(115200);
SerialBT.begin("PomPomBT");
Serial.println("The device started.");
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(10, 10);
M5.Lcd.setRotation(3);
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setTextSize(2);
M5.Lcd.printf("PomPom ON");
}
void loop() {
String cmd = String("AJ");
String eol = String("\r\n");
String cmdR;
if (SerialBT.available()) {
cmdR = SerialBT.readString();
if(cmdR == (cmd + eol)) {
SerialBT.println("Applejack is best pony !");
} else {
SerialBT.println("Pony doesn't received !");
}
}
delay(2000);
}