diff --git a/bluetooth_pairing.ino b/bluetooth_pairing.ino new file mode 100644 index 0000000..4ea891a --- /dev/null +++ b/bluetooth_pairing.ino @@ -0,0 +1,34 @@ +#include +#include "BluetoothSerial.h" + +BluetoothSerial SerialBT; + +void setup() { + SerialBT.begin("M5Stack-Vojta"); //Bluetooth device name + M5.begin(); +} + +void loop() { + if (SerialBT.available()) { + char ch=SerialBT.read(); + if(ch=='a' || ch=='A') + M5.Lcd.fillScreen(WHITE); + if(ch=='b' || ch=='B') + M5.Lcd.fillScreen(RED); + if(ch=='c' || ch=='C') + M5.Lcd.fillScreen(GREEN); + if(ch=='d' || ch=='D') + M5.Lcd.fillScreen(BLUE); + } + M5.update(); // update button state + if(M5.BtnA.isPressed()) { + SerialBT.println("Key A"); + } + if(M5.BtnB.isPressed()) { + SerialBT.println("Key B"); + } + if(M5.BtnC.isPressed()) { + SerialBT.println("Key C"); + } + delay(100); +}