Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj1711572002/69179b27a29953e632800af7e4fb5e36 to your computer and use it in GitHub Desktop.
Save dj1711572002/69179b27a29953e632800af7e4fb5e36 to your computer and use it in GitHub Desktop.
ESP32DevkitC Serial1 Test Jikken4
//HardwareSerial Serial2(2);//これは不要でいれるとエラーになる
void setup() {
// initialize both serial ports:
Serial.begin(115200);
//Serial2.begin(115200);
Serial1.begin(115200, SERIAL_8N1, 0, 4);//GPIO0:RX=pin25,GPIO4:TX=pin26
}
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