Serial2.ino 462 B

12345678910111213141516171819202122232425262728
  1. #include <M5Stack.h>
  2. void setup() {
  3. M5.begin();
  4. M5.Power.begin();
  5. Serial.begin(115200);
  6. // Serial2.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert)
  7. Serial2.begin(115200, SERIAL_8N1, 16, 17);
  8. pinMode(5, OUTPUT);
  9. digitalWrite(5, 1);
  10. }
  11. void loop() {
  12. if(Serial.available()) {
  13. int ch = Serial.read();
  14. Serial2.write(ch);
  15. }
  16. if(Serial2.available()) {
  17. int ch = Serial2.read();
  18. Serial.write(ch);
  19. }
  20. }