Bluetooth connection.
This commit is contained in:
parent
efc2a678d8
commit
c295dd299c
34
bluetooth_pairing.ino
Normal file
34
bluetooth_pairing.ino
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include <M5Core2.h>
|
||||||
|
#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);
|
||||||
|
}
|
Loading…
Reference in a new issue