35 lines
763 B
Arduino
35 lines
763 B
Arduino
|
#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);
|
||
|
}
|