I have an Arduino Mega and an ESP32 that I want to connect by serial communication. The thing is, pins 0 and 1 for RX/TX from Mega are not available because they are covered by a screen shield. So, I decided to use pins 18 and 19 for RX/TX, but with the classic code it doesn't work. How to define that I use pins 18 and 19 instead of 0 and 1? I mention that when connecting to pins 0 and 1, the communication works. I'll attach the code for both boards.
Arduino Mega:
basically I have problem with the read.String() that cannot read the data transfer from mega 2560 to esp32 through serial communication2. I hope someone can give to me the solution about my problem