/* Program 4-7: Echo the received characters of the Serial1 port of Mega * * Connect a 5V Serial to USB converter from the Mega to * the PC. Pin PD3 of the Mega is TxD1 and should be connected * to the Rx of the USB converter. Pin PD2 of the Mega is RxD1 * and should be connected to the Tx of the USB converter. * * Use a terminal emulator such as Tera Term or Putty to send * characters and see the output. */ void setup() { Serial1.begin(9600); /* initialize serial1 and set the Baud rate to 9600 */ } void loop() { while (!Serial1.available()) { } /* wait until a char is available */ char c = Serial1.read(); /* read the character */ Serial1.write(c); /* echo the character received */ }