Advertisement
j0h

2 baudrates

j0h
Jun 14th, 2020
1,398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #define ESPSerial Serial1
  2.  
  3.  
  4. void setup() {
  5.   // wait for hardware serial to appear
  6.   while (!Serial);
  7.  
  8.   // make this baud rate for the MCU
  9.   Serial.begin(115200);
  10.  
  11.   // 9600 baud rate for the EPS
  12.   ESPSerial.begin(9600);
  13. }
  14.  
  15.  
  16. void loop() {
  17.   if (Serial.available()) {
  18.     char c = Serial.read();
  19.     ESPSerial.write(c);
  20.   }
  21.   if (ESPSSerial.available()) {
  22.     char c = ESPSerial.read();
  23.     Serial.write(c);
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement