// send an int from one serial to another serial.
#define RXD1 16
#define TXD1 17
#define RXD2 21
#define TXD2 22
int a = 1;
// int a = -500;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Hello, ESP32!");
Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2); //
}
void loop() {
Serial.print("sending: ");
Serial.println(a);
Serial1.print(a); // print a to serial 1
a++;
delay(500);
if (Serial2.available() > 0) { // Check if data is available to read on serial 2
int b = Serial2.parseInt(); // Read the incoming integer on serial2 and store it in 'x'
Serial.print("Received: ");
Serial.println(b); // Print the received integer to serial monitor
}
delay(10); // this speeds up the simulation
}