Skip to content

Instantly share code, notes, and snippets.

Created March 30, 2011 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/893962 to your computer and use it in GitHub Desktop.
Save anonymous/893962 to your computer and use it in GitHub Desktop.
Arduino sketch for serial passthrough
/**************************************************
* Simple pass-through serial application for
* Arduino and Arduino-clones.
* You can use this for testing and
* updating the Rogue Robotics
* uMMC Serial Data Module or
* uMP3 Playback Module.
*
* You will need the "NewSoftSerial" library
* available at the Arduino website.
* http://arduino.cc/
* http://arduino.cc/en/Reference/Libraries
***************************************************/
#include <NewSoftSerial.h>
// You can set this to whatever pins you have the uMMC or uMP3 connected.
// e.g. 4 is connected to uMMC "T", 5 is connected to uMMC "R"
NewSoftSerial out(7, 8);
// If you are using this to update the firmware on the uMMC or uMP3,
// you will have to make sure that both the Serial connection and the
// out connection are set to 9600 bps.
void setup()
{
out.begin(19200);
Serial.begin(19200);
// pinMode(13, OUTPUT);
// digitalWrite(13, 0);s
}
void loop()
{
// digitalWrite(13, 0);
if(out.available())
{
// digitalWrite(13, 1);
Serial.print((uint8_t)out.read());
}
if(Serial.available())
{
// digitalWrite(13, 1);
out.print((uint8_t)Serial.read());
}
}
@anton-matosov
Copy link

anton-matosov commented Jun 14, 2017

Correct loop:

void loop()
{
    while (Serial.available())
    {
        out.print((char)Serial.read());
    }

    while (out.available())
    {
        Serial.print((char)out.read());
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment