Solved!! LCD question... hello world example doesnt work but other code does

Hello I have been draw to the arudino world its been fun so far!
just got my board a couple days ago, I been doing all the examples.
Now I am trying to do the LCD Hello World example.

It prints wierd stuff to the screen
The screen I have is a Seiko Instruments 20x4 5x7 char model #L2034-00J I got it free so why not use it :slight_smile: I do have the data sheet for it.

The only time I can see Hello world is when I use this code below... but modified one of his lines of code to say lcd.print("Hello World"); instead of lcd.print(thisLetter, BYTE); because when I compiled (using Visual Studio 2010) it reported BYTE is not used no more use Serial.write this confused me so I just threw "hello world" in and it does print hello world and scrolls it thru the screen witha bunch of H's)

/*
LiquidCrystal Library - setCursor

Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.

This sketch prints to all the positions of the LCD using the
setCursor(0 method:

The circuit:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2

Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 August 2009
by Tom Igoe

*/
// include the library code:
#include <LiquidCrystal.h>
// these constants won't change. But you can change the size of
// your LCD using them:
const int numRows = 4;
const int numCols = 20;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(numRows, numCols);
}
void loop() {
// loop from ASCII 'a' to ASCII 'z':
for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
// loop over the rows:
for (int thisRow= 0; thisRow < numRows; thisRow++) {
// loop over the columns:
for (int thisCol = 0; thisCol < numCols; thisCol++) {
// set the cursor position:
lcd.setCursor(thisCol,thisRow);
// print the letter:
lcd.print("Hello World");
//lcd.print(thisLetter, BYTE); (orignal code used this line but I was getting a error saying BYTE is not used no more use Serial.write this confused me so I just threw "hello world" in and it does print hello world and scrolls it thru the screen witha bunch of H's)
delay(200);
}
}
}
}
So my wiring is correct, and I used the wiring shown in the example for hello world, but how can I do simple words to the screen rather then using the above code. I only tried this code because the LiquidCrystal.h does not define my screen which uses 5x7 dots.
any help would be great. Thanks
I have spent alot hours searching before I asked this question, so just need a bump in the right direction.
Thanks
Brian

Looks like you have a bunch of loops left over from some previous example. Try changing setup() and loop() to:

 void setup() {
   // set up the LCD's number of rows and columns: 
   lcd.begin(numRows, numCols);
   lcd.setCursor(0,0);
   lcd.print("Hello World");
 }
 void loop() { }

Thanks fro the reply, I removed all the loops and did as you suggested (No errors) but doesnt print anything, so I changed cursor position and still nothing. Went back to other code and it still the same.
Question
Since my screen uses 5x7 char don't I have to change the include file LiquidCrystal.h to define ASCII 5x7 char table?
-But then again why does Hello world work with the loop code I copied, and also scroll hello world thru the screen on different rows.

I ordered a new LCD screen that will work with the LiquidCrystal.h file 20x4 with 5x8char, but darn thing wont be here till end of the month. There is no way I can put this down until then. LOL

I am still digging around online, my line of thought is the LiquidCrystal.h file needs changed or I need to include a different one for my model of LCD.
Brian

OK I played around some, I now I am thinking its just a timing issue. So I going to do some research on how to change the timing correctly.

Feel free to pipe in thou.. :slight_smile:

Brian

Since my screen uses 5x7 char don't I have to change the include file LiquidCrystal.h to define ASCII 5x7 char table?

There's no reason for you to have to change anything in LiquidCrystal. Even if this were an issue it would be handled by the character generator ROM that is part of the LCD controller.

I am thinking its just a timing issue.

I doubt it.

See if this information will help: http://arduino.cc/forum/index.php/topic,95984.msg720669.html#msg720669

Don

I used the following code example Don sent me in a link.
#include <LiquidCrystal.h>

//LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // put your pin numbers here

void setup()
{
lcd.begin(20, 4);
for (char i=47; i<127; i++) // send 80 consecutive displayable characters to the LCD
{
lcd.print(i);
delay(100); // this delay allows you to observe the addressing sequence
}
}
void loop()
{
}
LCD screen fills the first line, then third, then 2nd, and last forth (this is normal I think). Same char displayed every time I load the sketch.

Here is some pictures of what shows up on my screen.
The first pic is with the code in this attachment.

The second Picture is with the the code I posted with all the loops. What you see on the screen is a bunch of weird text scrolling at first load, then couple seconds later the "Hello world" starts scrolling throw first line, then 3rd, then 2nd, then 4th, appears to be char overrun. but while its doing this the H stays behind and covers the weird unknown text. I can get it to display hello world standing still by using the loop code and inserting lcd.setCursor(0,0); after the loops. But Never with complete removal of the loops. Screen is either blank or weird depending code.

void loop() {

// loop from ASCII 'a' to ASCII 'z':
for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
// loop over the rows:
for (int thisRow= 0; thisRow < numRows; thisRow++) {
// loop over the columns:
for (int thisCol = 0; thisCol < numCols; thisCol++) {
// set the cursor position:
lcd.setCursor(thisCol,thisRow);
lcd.setCursor(0,0); // <- If I use this line of code a bunch of wierd text shows on # lines, after 3sec Hello World!!!! appears
// print the letter:
lcd.print("Hello World!!!!");
delay(200);
}
}
}

I hope someone can figure this out so I don't have to wait till the newer LCD comes, I got this one back in 2004 with a different programming kit I had.

Thanks Brian

BY the way this is the screen I have
http://www.distrelec.com/ishopWebFront/catalog/product.do?language=en&shop==YY&series=1&id=01&node=44151&artView=true&productNr=633350

Features of L2034 Series
? 20 characters ´ 4 lines
? STN LCD is used
? 5 ´ 7 dot matrix + cursor
? 1/16 duty
? 5V single power supply


I added "lcd.print(millis()/1000);" after the Hello world and it does count in seconds on the screen after the hello world!!!! appears. However I am still getting garbage first and then 3 seconds later I get Hello World!!! and now with seconds counting up after it.
Also I am still not able to get Hello WOrld to appear without using the following code
void loop() {

// loop from ASCII 'a' to ASCII 'z':
for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
// loop over the rows:
for (int thisRow= 0; thisRow < numRows; thisRow++) {
// loop over the columns:
for (int thisCol = 0; thisCol < numCols; thisCol++) {
// set the cursor position:
lcd.setCursor(thisCol,thisRow);
lcd.setCursor(0,0); // <- If I use this line of code a bunch of wierd text shows on # lines, after 3sec Hello World!!!! appears
// print the letter:
lcd.print("Hello World!!!!");
lcd.print(millis()/1000);
delay(200);
}
}
}

I bet this is such an easy question you guys are all Lyao... but I am not LOL.
Stumped bad.

LCD screen fills the first line, then third, then 2nd, and last forth (this is normal I think).

Correct.

Same char displayed every time I load the sketch.

I think you mean the same sequence of characters .... This would indicate that you are not getting random errors.

Here is some pictures of what shows up on my screen.
The first pic is with the code in this attachment.

Now you have to compare the binary values for the characters that you are sending to the display to the binary values for the characters that you are seeing on the display. You will probably find that you have a bit stuck high or low or two adjacent bits tied together.

Without doing this analysis I would suggest starting out by looking at D4 since this will have the least effect on the initialization (which obviously worked).

Don

Well Don I think if I did have 2 bits shorting or one stuck high, it would never say "hello world" and wouldn't scroll hello world thru all the lines on the screen. I also tried bits 7,8,9,10 same thing.
I give up, for today, I got go eat dinner.
Has to be something weird about this older LCD. I been messing with delay commands no luck there either.
Thanks for your help Don, I will check double check wires and bits tmrw, but I think problem lies else where.

While you are doing your LCD troubleshooting you should avoid doing anything in loop().

Why not try something simple like this:

#include <LiquidCrystal.h>

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      // put your pin numbers here

void setup()
  {
  lcd.begin(20, 4);                          // put your LCD parameters here
  lcd.print("This is line 1");
  lcd.setCursor(0,1)
  lcd.print("This is line 2");
  lcd.setCursor(0,2)
  lcd.print("This is line 3");
  lcd.setCursor(0,3)
  lcd.print("This is line 4");
  }

void loop()
  {
  }

Don

Hey Don Thanks I tried that doesn't work just a blank screen.
I think I found the problem its because my LCD uses a older KS0066 controller, and after a lot of googling I found a guy that had a same problem. I am going to try his LCD4Bit.h fix as soon as I get my computer back, its currently doing a huge update from microsoft.

If it works then I will make sure this info is logged well for others to find. by the way here is the guys web page link to simular issue
http://www.tekcrack.com/interfacing-arduino-with-a-purdy-lcd-4x40-modified-lcd4bit-library.html

Take care
Brian

... my LCD uses a older KS0066 controller...

Older??? Do you have any idea how old the HD44780 controller (the one that the KS0066 and ALL the others are based on) is? I was using it in 1990 and it was old then.

Please do everyone a favor and do not post any links concerning the obsolete and poorly written LCD4bit library.

Also do yourself a favor and don't waste your time with any derivative of that library.

Don

Wow the 90's! holy cow
Thanks for the heads up, I was just about to dig into that. I got side tracked been working on some other cool stuff this arduino does. I saw that after I posted that last comment, someone said dont use lcd4bit. LOL I am probably going to give up on this LCD, it is wierd how it works pretty good with the loop commands, I still think its got something to do with the liquidcrystal.h setup with timing or something. But hey you would know better then anyone, I completely tour it down and wired it up on another board I have, sure enough same output char. and this time I wired it up and ran ladyada code using upper bits. Same results, so I for surely know its not wiring or the bread board.
Honestly I have read a lot of issue people had with this same controller and or just slower lcd's, and it appears mine has 2 of these controllers one running line 1 n 3 other runs line 2 n 4. I will probably play around with it few more times tonight. I did order a different one wont be here unitl end of the month :frowning: Maybe I will go tear a LCD out of something I have laying around... ha ha Thanks Don for the advice I wont touch that older 4bit lib. But what about the the liquidcrystal1.0 lib i read it works better with slower control chips? What you think Don?
Thanks
Brian

so I for surely know its not wiring or the bread board.

You haven't given us a chance to look at the wiring or at your soldering.

and it appears mine has 2 of these controllers

You should have one controller and four auxiliary controllers. Sometimes there appear to be two auxiliary controllers because there are two in each epoxy blob.

one running line 1 n 3 other runs line 2 n 4

Not exactly....

Why don't you start again from scratch.
First hook up just the power (pins 1, 2, and 3) and make sure you get a single row of blocks and make sure that you can adjust the contrast.
Then add the six connections to the Arduino and the GND on LCD pin 5 and run the code from reply #10.
If you got the single row of blocks in the first step then the screen should not be blank now.

Don

I just removed all but first three wires on the LCD, my first and 3rd line light up and yes the contrast works. 2 controllers maybe?

ok just rehooked wires up, I will attach a picture, I never soldered anything, my lcd came with male headers. Nothing flaky about it, it prints to the screen just fine when using this code
// loop from ASCII 'a' to ASCII 'z':
for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
// loop over the rows:
for (int thisRow= 0; thisRow < numRows; thisRow++) {
// loop over the columns:
for (int thisCol = 0; thisCol < numCols; thisCol++) {
// set the cursor position:
lcd.setCursor(thisCol,thisRow);
lcd.setCursor(0,0); // <- If I use this line of code a bunch of wierd text shows on # lines, after 3sec Hello World!!!! appears
// print the letter:
lcd.print("Hello World!!!!");
lcd.print(millis()/1000);
delay(200);
}
}
}
When I use this code the screen is filled with black boxes
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // put your pin numbers here

void setup()
{
lcd.begin(20, 4); // put your LCD parameters here
lcd.print("This is line 1");
lcd.setCursor(0,1);
lcd.print("This is line 2");
lcd.setCursor(0,2);
lcd.print("This is line 3");
lcd.setCursor(0,3);
lcd.print("This is line 4");
}

void loop()
{
}

Here is pictures. I took 2 pictures from different angles and I am using LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
If anyone finds I wired something wrong I will be LMAO! cause I checked and rewired 3times now several different ways and all my other projects work great! even the servo motor control. Btw that chip is not being used it just sitting there from my motor control i did.
Its not pretty wiring but you can see it, and this is the second breadboard too. every time variable same result.
thanks
Brian

Ok it is only one controller chip i see that now in the spec sheet. https://www.distrelec.com:443/ishop/Datasheets/07555105.pdf
Does anyone know the timing numbers off hand for the liquidcrystal.h? Somehow I need to compare these with the ones in my spec sheet. My thinking may be way off but I think when it runs the code with the loop, "for" and "> or <" it slows it up enough to make it work. Thats why this very same code does work correctly for the first 3 seconds, then HEllO world scrolls thru all the lines one at a time. But right after reset the screen clrs and then wierd text comes up, always the same weird text, then followed by Hello World!!!.
Its almost like it just takes time to initialize or something. I don't know seems like timing to me.
Brian

I just removed all but first three wires on the LCD, my first and 3rd line light up and yes the contrast works. 2 controllers maybe?

No, just one controller. I forgot that you were using a 20x4 display - on those displays the first and third lines will have blocks.

Ok it is only one controller chip i see that now in the spec sheet.

What do you see on the back of the PC board? Probably three or five blobs of epoxy.

it prints to the screen just fine when using this code

Please post all of the code. Is this snippet in setup() or is it in loop(). If it is in loop() you are wasting our time - you must get the static display working first.

If I use this line of code a bunch of wierd text shows on # lines, after 3sec Hello World!!!! appears

For each variation we need to see a copy of the actual code along with a picture of the result. The exact 'weird' text is important, especially if it is the same each time.

When I use this code the screen is filled with black boxes

In reply #11 you said that when you use this code the screen is blank.

Here is pictures.

They aren't clear enough for my eyes and some of the wires run out of the picture so I can't follow them.

Does anyone know the timing numbers off hand for the liquidcrystal.h?

It is possible that you have a display with a controller that is out of spec (running slower than normal). Unfortunately there is nothing in LiquidCrystal.h that has anything to do with timing.

Somehow I need to compare these with the ones in my spec sheet.

Unfortunately the spec sheet in your link does not have any timing information.

You could try using the LiquidCrystal1.0 library. This is the latest version of LiquidCrystal440 which was written for 40x4 displays but also works with the more common displays. I believe that it does a better job with 'slow' LCD controllers. Start here: http://code.google.com/p/liquidcrystal440/.

Did you notice the difference in the appearance on my code versus the appearance of yours. After you paste in your code you should highlight it and use the 'Code' button (which looks like a '#' symbol).

Don

Ok it is only one controller chip i see that now in the spec sheet.

What do you see on the back of the PC board? Probably three or five blobs of epoxy.
on the back of the LCD is 4 oki chips and one glob top chip

it prints to the screen just fine when using this code

Please post all of the code. Is this snippet in setup() or is it in loop(). If it is in loop() you are wasting our time - you must get the static display working first.
OK yes this is with loop() so it is a waste of time :slight_smile: but at least i know the wiring is right.

#include <LiquidCrystal.h>
 const int numRows = 4;
 const int numCols = 20;
// initialize the library with the numbers of the interface pins
 LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
 void setup() {
	lcd.begin(numRows, numCols);
 } 
 void loop() {
   // loop from ASCII 'a' to ASCII 'z':
   for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
     // loop over the rows:
     for (int thisRow= 0; thisRow < numRows; thisRow++) {
       // loop over the columns:
       for (int thisCol = 0; thisCol < numCols; thisCol++) {
         // set the cursor position:
       lcd.setCursor(thisCol,thisRow);
	      //lcd.setCursor(0,0);
		   // print the letter:
		 lcd.print("Hello World!!");
		 //lcd.print(millis()/1000);
		 //lcd.print(i);
         delay(200);
      }
     }
   }  
 }

If I use this line of code a bunch of wierd text shows on # lines, after 3sec Hello World!!!! appears

For each variation we need to see a copy of the actual code along with a picture of the result. The exact 'weird' text is important, especially if it is the same each time.
This one was also with a loop ...

When I use this code the screen is filled with black boxes

In reply #11 you said that when you use this code the screen is blank.

#include <LiquidCrystal.h>

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
 LiquidCrystal lcd(7, 8, 9, 10, 11, 12);// put your pin numbers here

void setup()
  {
  lcd.begin(20, 4);                          // put your LCD parameters here
  lcd.print("This is line 1");
  lcd.setCursor(0,1);
  lcd.print("This is line 2");
  lcd.setCursor(0,2);
  lcd.print("This is line 3");
  lcd.setCursor(0,3);
  lcd.print("This is line 4");
  }

void loop()
  {
  }

Yes That last reply was wrong this code produces a blank screen. sorry about last comment.

Here is pictures.

They aren't clear enough for my eyes and some of the wires run out of the picture so I can't follow them.
I didn't include the wires for the pot because that all works great. I figured you just wanted to see the data lines. I am wanting to try liquidcrystal1.0 however I attempted to try liquidcrystal440 couple days ago but stopped because when I copied the lib zip file over it wanted to write over my existing liquidchrystal, I assumed it would be named different but its not. So now after reading some I found I am suppose to rename my other liquidcrystal and then unzip the liquidcrystal1.0 . Is this right? seems silly I have to rename everything again if I use a different LCD, wonder why they cant come up with different names so they can all be in the same folder and then we can just #include the one we need for that project, like any other include file.

Does anyone know the timing numbers off hand for the liquidcrystal.h?

It is possible that you have a display with a controller that is out of spec (running slower than normal). Unfortunately there is nothing in LiquidCrystal.h that has anything to do with timing.

Somehow I need to compare these with the ones in my spec sheet.

Unfortunately the spec sheet in your link does not have any timing information.

You could try using the LiquidCrystal1.0 library. This is the latest version of LiquidCrystal440 which was written for 40x4 displays but also works with the more common displays. I believe that it does a better job with 'slow' LCD controllers. Start here: Google Code Archive - Long-term storage for Google Code Project Hosting..
I just downloaded liquidcrystal1.0 lib, I guess I will just rename my old folder but I think visual studio isnt going to like me doing that.

Did you notice the difference in the appearance on my code versus the appearance of yours. After you paste in your code you should highlight it and use the 'Code' button (which looks like a '#' symbol).
Ya I did I was wondering how you did that! kickazz! thanks
Don
[/quote]

I forgot to add the pictures, Here is a picture using the simple setup code, and lcd.print("helloworld!"; 2 times. see picture. It seems my LCd screen is stuck in some special character mode. Would timing produce the same screen prints, seems link timing would be more random, but I don't know. Also I have no clue what the ascII of this print screen is.. LOL
There should be 13 char on the screen, but only 11 show, and if you look close the kinda (Z) thing should be the (L's of "hello" and "world"), so it appears the (H) does not ever get printed, maybe it is timing. And the timing is what causes the special char as well. Dam I got move the lib and try liquidcrystal1.0
Take care thanks

[code]#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
    lcd.begin(20, 4);
    lcd.print("hello, world!");
  lcd.print("hello, world!");
  
}
void loop() {
   //lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  //lcd.print(millis()/1000);
}

[/code]