// Can other Serial/UARTS ports redirect to the Serial Monitor ?
// Answer: Yes.
//
// Reference: https://reference.arduino.cc/reference/en/language/functions/communication/serial/
//
// Mega 2560 Rev3:
// Serial = 0(RX), 1(TX)
// Serial1 = 19(RX1), 18(TX1)
// Serial2 = 17(RX2), 16(TX2)
// Serial3 = 15(RX3), 14(TX3)
//
// file "diagram.json" for Serial1:
// "connections":
// [
// [ "mega:19", "$serialMonitor:TX", "" ],
// [ "mega:18", "$serialMonitor:RX", "" ]
// ]
//
// This project: https://wokwi.com/projects/424176908696674305
// See also the test with Uno: https://wokwi.com/projects/424176849827515393
#define _SERIAL Serial3
unsigned long count;
void setup()
{
_SERIAL.begin(115200);
_SERIAL.println("Hello Mega");
}
void loop()
{
_SERIAL.print(count++);
_SERIAL.print(" ");
if(_SERIAL.available() > 0)
{
_SERIAL.println();
while(_SERIAL.available() > 0)
{
int inChar = _SERIAL.read();
if(isprint(inChar))
_SERIAL.write(inChar);
}
_SERIAL.println();
}
delay(1000);
}