Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
M5Core2_Serial1_GPIO19RX-GPIO27TX TEST
//HardwareSerial Serial2(2);//これは不要でいれるとエラーになる
#include <M5Core2.h>
void setup() {
// initialize both serial ports:
//Serial.begin(115200);
M5.begin();//この中でSerial(USB Serial)の115200宣言含む
//Serial2.begin(115200);
Serial1.begin(115200, SERIAL_8N1,19, 27);//GPIO19:RX ,GPIO27:TX
}
void loop() {
// read from port 1, send to port 0:
if (Serial1.available()) {
int inByte = Serial1.read();
Serial.print("Recieved=");
Serial.println(inByte);
}
// read from port 0, send to port 1:
if (Serial.available()) {
int inByte = Serial.read();
Serial.print("KeyIn=");
Serial.println(inByte);
Serial1.write(inByte);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment