From c295dd299c29e8d64a76f2e9753fc61f4170b894 Mon Sep 17 00:00:00 2001 From: BigTire Date: Tue, 15 Nov 2022 11:02:45 +0100 Subject: [PATCH] Bluetooth connection. --- bluetooth_pairing.ino | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bluetooth_pairing.ino 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); +}