I have the following circuit and want to use the Arduino Mega 2560 as an debugger for an other Microcontroller. circuit

So I am looking for the code to redirect the UART input from "P17 (RX2)" to the serial USB and the data coming from the serial USB to the output of "P16 (TX2)"

  • Is the Arduino going to do anything other than forward serial data? – Ignacio Vazquez-Abrams Sep 10 '14 at 16:24
  • @IgnacioVazquez-Abrams no just forwarding – kimliv Sep 10 '14 at 17:08
  • Then why use an Arduino at all? USB-to-UART bridges are much cheaper. – Ignacio Vazquez-Abrams Sep 10 '14 at 17:09
  • @IgnacioVazquez-Abrams I know but i am not at home and here I have a Arduino Mega 2560 but no USB-to-UART bridge. So why not using the Arduino than not to be able to debug at all? – kimliv Sep 10 '14 at 17:12

A very simple sketch to pass serial through looks like this:

void setup(){

void loop(){

I would advise both run at the same baud rate, otherwise you may need to do some extra buffering yourself if the arduino starts running out of buffer space. If you want to use the mega's USB connection instead of "Serial1" like your schematic, just switch "Serial1" to "Serial"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.