Skip to content

Instantly share code, notes, and snippets.

Created Mar 30, 2011
Embed
What would you like to do?
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