Problems working with a sparkfun 16x2 serial LCD

Hello community,

This is my first post and I am just getting into working with an arduino. I am having issues getting a spakfun serial 16x2 LCD (sparkfun part number LCD-09395) to work.

I am using an Arduino Uno Rev3 with a 16x2 serial LCD.
I am powering the arduino with my computer's USB port

I followed the "Quickstart" guide https://www.sparkfun.com/tutorials/246 from sparkfun for hooking the LCD up and looked at the SerLCD data sheet https://www.sparkfun.com/datasheets/LCD/SerLCD_V2_5.PDF though my LCD is differnt than the one pictured), but I am not having any success getting my LCD to work as I intend it to. I even tried using a second LCD (same model), but no luck.

With the first LCD, I was having issues with garbage characters being printed on the LCD along with the intended text.
While I was trying different snippets of code, along with the commands from the datasheet, the garbage characters were still there, but I managed to turn off the back light, and it will not turn back on.
Again I tried several different snippets of code available on the net, but no success. When I unplug the USB and plug it back in, the backlight flashes quickly and then stays off.

Next attempt on another LCD, no garbage characters (strangely), and I could get text to print out (sweet feeling better), but in trying to program in a carriage return using Serial.print('\n'); the LCD turned off and I can't get it to turn back on. Again I tried several snippets of code available on the net, but no success.

Another issue that I was having was when I used "upload" in Arduino 1.0.5, the LCD would just print out garbage, until I unplugged the usb and plugged it back in.

Is this the usual procedure?
How can I get the backlight back on?
Where do the garbage characters come from?
What code source would be the correct one for this LCD?

I apologize for all the questions and different issues, but I wanted to write all that I have tried and all the issues that I ran into along the way.
I would appreciate any assistance and any light that anyone can shed on these issues.

Many thanks in advance,

wc

You can't print to the LCD the same way you do on a computer, carriage return '\n' = 13 =0x0D. Look in the PDF you linked at table 3.3 on page 2, you'll see that 0x0D turns the display off, 0x0C turns it on.
You have to use setCursor in order to change lines.
After you get the 2nd display working right, try to connect the first one you tried and see if there's still garbage. If there is take a picture and upload it so we can see, and attach the source code.

Hi, and welcome.

Your links do not work (for me).

To program your Arduino, the serial connections are in use, through the USB / serial converter chip.
If you have anything connected to the serial ports while programming, that unit will receive seemingly random stuff.
So that question is answered: Yes, it's normal.
However, because you can also send control signals to the module, it's not a good idea to have your LCD connected during upload because you do not know what you're sending it.

The backlight can be set (according the document you attempted to link to)by sending it:

Serial.print(124);
Serial.print(157);

See that there are no ' or " between the brackets ?
That means you're sending a value instead of a character.
The second one sets the level and can be a value between 128 for off and 157 for maximum level.

It is a bit of a shame they chose for this approach, because 124 represents a usable character "|".
But that what they chose to use nearly 10 years ago.

If you are sending texts longer than 1 single character, use " like:

Serial.print ("More characters");

Some more general:
The display is supposed to display what you send it.
If you send it "First Attempt", and next send it "2nd Attempt" on the same line, you will get:
2nd Attemptpt
That is because you did not clear the older text.
You can clear by sending spaces, or by clearing the entire screen (which is essentially the same).

Hello, thank you for your responses. It was an issue of the display being turned off by sending Serial.print(13) or Serial.print(0x0D).
Also the garbage characters were most definitely form using the USB to power the Arduino. Garbage was being read from the USB port, messing up the display output.

For anyone whom the links don't work for, just copy and paste the urls in your browser bar.

It was strange as I am trying the commands, Serial.print(13) would just print "13" on the LCD and Serial.print(14) would just print "14" on the LCD. Same for their Hex equivalents.
I then switched serial ports on my computer (macbook) from /dev/tty.usbmodem1a21 to /dev/cu.usbmodem1a21 and it would work.

Any ideas?

The difference is that Serial.print (13); sends character 13 or display off, and Serial.print("13"); will send an array or string that consists of characters 49 and 51 which makes up "13".
Check your codes to see the differences.
In case there's no difference in those codes, there might be something wrong with the display or better it's PIC controller ]:smiley: .
But that's quite unlikely.

i am not sure the exact model of LCD screen i have, but it is a yellow text on blue background 16x2. i am having problems too, only mine works fine, but the display is too dim to read in even a well lit room. i was wondering if you could post your code that you made work, as mine doesnt seem to have anything that could control a backlight. i am using the standard code from the arduino library, so im not sure if thats part of the problem or if its the part. as ive read the specific one i have is faulty in this regard.

thanks, eron.

eron,

post pictures of the front and back of your LCD and we might be able to work out what type you have and therefore, find it's datasheet which will help a lot with diagnosing your problem.

MAS3:
To program your Arduino, the serial connections are in use, through the USB / serial converter chip.
If you have anything connected to the serial ports while programming, that unit will receive seemingly random stuff.
So that question is answered: Yes, it's normal.
However, because you can also send control signals to the module, it's not a good idea to have your LCD connected during upload because you do not know what you're sending it.

Thanks so much for this. I'm new to Arduino as well, and it was driving me CRAZY trying to figure out why I couldn't get anything to display correctly.