I spent a few hours this morning trying to make a device that would make my real life job easier- a serial port message reporting device. However, in order to use the SparkFun led display I needed a second serial port. I had a bunch of really complicated ideas, but then saw the tutorial on
software serial communications. Since all I need to talk to the LED (with a serial backpack) is one 9600 baud tx, I hooked it up, adjusted the defined delay slightly, and it worked like a champ.
Added a switch to cycle through baud rates on the receiving end, and cut out everything above 28800 because it didn't seem to work at all. I didn't troubleshoot this, as most of the communications I want to listen to are at 9600 baud... I also block any characters that either don't have an associated graphic on my led or are one of the reserved command bytes and replace them with character 174, which looks like a little E on my led.
here's the code:
//Created August 15 2006
//Heather Dewey-Hagborg
//Modified February 25 2007
//Richard Shields
//Modifications: Adjusted to only include software serial out,
// takes serial in from pin 1 at adjustable baud rate and
// retransmits those values to a 9600 baud serial display
//http://www.arduino.cc
#include <ctype.h>
#define bit9600Delay 92
#define halfBit9600Delay 42
#define bit4800Delay 188
#define halfBit4800Delay 94
byte tx = 7;
byte switchBaud = 10;
byte switchSet = 0;
byte SWval;
int charCount = 0; // variable to clear display when it gets full
int serialRate = 4800; // change serial rate with this variable
void setup() {
Serial.begin(serialRate); // open the hardware serial port
pinMode(tx,OUTPUT);
pinMode(switchBaud,INPUT);
digitalWrite(tx,HIGH);
digitalWrite(13,HIGH); //turn on debugging LED
SWprint(254); // LED control message begin
SWprint(1); // Clear the display
SWprint('S');
SWprint('e');
SWprint('r');
SWprint('i');
SWprint('a');
SWprint('l');
SWprint(' ');
SWprint('M');
SWprint('o');
SWprint('n');
SWprint('i');
SWprint('t');
SWprint('o');
SWprint('r');
SWprint(' ');
SWprint(' ');
SWprint('R');
SWprint(' ');
SWprint('S');
SWprint('h');
SWprint('i');
SWprint('e');
SWprint('l');
SWprint('d');
SWprint('s');
SWprint(' ');
SWprint(' ');
SWprint('B');
SWprint('B');
SWprint('I');
delay(3000);
changeBaud();
}
void SWprint(int data)
{
charCount++;
byte mask;
//startbit
digitalWrite(tx,LOW);
delayMicroseconds(bit9600Delay);
for (mask = 0x01; mask>0; mask <<= 1) {
if (data & mask){ // choose bit
digitalWrite(tx,HIGH); // send 1
}
else{
digitalWrite(tx,LOW); // send 0
}
delayMicroseconds(bit9600Delay);
}
//stop bit
digitalWrite(tx, HIGH);
delayMicroseconds(bit9600Delay);
}
void changeBaud() {
SWprint(254); // LED control message begin
SWprint(1);
SWprint('B');
SWprint('a');
SWprint('u');
SWprint('d');
SWprint(':');
SWprint(' ');
switch (serialRate) {
case 300:
serialRate = 1200;
SWprint('1');
SWprint('2');
SWprint('0');
SWprint('0');
break;
case 1200:
serialRate = 2400;
SWprint('2');
SWprint('4');
SWprint('0');
SWprint('0');
break;
case 2400:
serialRate = 4800;
SWprint('4');
SWprint('8');
SWprint('0');
SWprint('0');
break;
case 4800:
serialRate = 9600;
SWprint('9');
SWprint('6');
SWprint('0');
SWprint('0');
break;
case 9600:
serialRate = 14400;
SWprint('1');
SWprint('4');
SWprint('4');
SWprint('0');
SWprint('0');
break;
case 14400:
serialRate = 19200;
SWprint('1');
SWprint('9');
SWprint('2');
SWprint('0');
SWprint('0');
break;
case 19200:
serialRate = 28800;
SWprint('2');
SWprint('8');
SWprint('8');
SWprint('0');
SWprint('0');
break;
case 28800:
serialRate = 300;
SWprint('3');
SWprint('0');
SWprint('0');
break;
default:
serialRate = 9600;
SWprint('9');
SWprint('6');
SWprint('0');
SWprint('0');
break;
}
Serial.flush();
Serial.begin(serialRate); // open the hardware serial port
delay(750);
SWprint(254); // LED control message begin
SWprint(1); // Clear the display
charCount = 1; // reset character count
}
void loop()
{
if (digitalRead(switchBaud) == HIGH) {
if(!switchSet) {
changeBaud();
}
} else {
switchSet = 0;
}
if (Serial.available() > 0) {
if (charCount > 32) {
SWprint(254); // LED control message begin
SWprint(1); // Clear the display
charCount = 1; // reset character count
}
SWval = Serial.read();
if ((SWval > 31) && (SWval != 124) && (SWval != 254) && ((SWval < 129) || (SWval > 160))) {
SWprint(SWval);
} else {
SWprint(174);
}
}
}
Here is the hardware, but don't hook this up directly to a serial port; I'll be revising the drawing after I play with the hardware tomorrow. The serial connector and circuit are probably going to look a lot like the rs232 connection on the original Arduino schematic...

-richard