Sparkfun Serial LCD

I have absolutely no idea if this will help anyone. I just know when I was looking around for help on using my Sparkfun serial enabled LCD (9600 bps) with the new Arduino 1.0 and SoftwareSerial, I wasn’t finding a lot of direct answers on getting my code working. After an afternoon of tinkering, I finally came up with a piece of code that works! It’s simple, just flashes “Hello world!” every second, but it works. From this example, and reading the datasheet for the SerLCD 2.5, hopefully most people can get enough info to help then with their project. Here it goes anyway:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10); // mySerial(rx, tx);

void setup()
{
mySerial.begin(9600);
}

void loop()
{
mySerial.print(" Hello world!");
delay(1000);
mySerial.write(0xFE);
mySerial.write(0x01);
delay(1000);
}

That’s it. Use mySerial where I use to use Serial and anywhere you are sending byte information, like commands, use mySerial.write instead of mySerial.print. Make sure you have the right rx and tx pins chosen. Make sure you have the right baud rate for your LCD.
That’s all I can’t think of now.

You posted what should be done to get correct results. For sake of other readers, can you post what you did wrong and symptoms? Then anyone reading this realizing making the same mistake can get instantly helped.

You should highlight the appropriate text and use the [u]code[/u] button when posting code. Some comments would also be appropriate - to identify the 'magic numbers'.

Don

Wow! It’s hard to remember everything. The main two things that come to mind were using Serial.print and Serial.write rather than mySerial.print and mySerial.write. Never could get anything to work that way. Also the void setup() format of “SoftwareSerial mySerial(9, 10)” wasn’t clear to me. Couldn’t remember which came first rx or tx. The way the default SoftwareSerialExample is arranged is not the easiest to understand, in my opinion.

I HATE the darn ‘code’ button! I hate the way code is put into those little scrolling windows. :frowning:
I often search on the forum and when I find information I need, I print the forum discussion to PDF so I can reference it later. Those darn code boxes mess up the printed output. You only get the visible part of the code showing and it cuts off the rest! Really sucks, in my opinion. I MUCH prefer standard text. Nuff said.

Here is the code again, with more comments:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10); // mySerial(rx, tx) declares pins for LCD use

void setup()
{
mySerial.begin(9600); // sets baud rate for LCD
}

void loop()
{
mySerial.print(" Hello world!"); // prints “Hello world!” in middle of top line
delay(1000); // one second delay
mySerial.write(0xFE); // COMMAND instruction for this LCD (byte)
mySerial.write(0x01); // clears display (byte)
delay(1000); // one second delay
}

At least one of your comments is wrong and two others are worthless. The reason that your original program did not work and the reason that this one appears to work is obvious.

Don