Go Down

Topic: Solved!! LCD question... hello world example doesnt work but other code does (Read 2 times) previous topic - next topic

bingles

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 :) 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
 
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */
// 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

johnwasser

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

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() { }
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

bingles

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


bingles

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.. :)

Brian

floresta

Quote
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.

Quote
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

bingles

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



bingles

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
_________________________________

bingles

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.

floresta

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

Correct.

Quote
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.

Quote
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

bingles

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. 

floresta

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

Why not try something simple like this:


Code: [Select]
#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

bingles

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
 

floresta

Quote
... 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

bingles

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 :( 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

floresta

Quote
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.

Quote
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.

Quote
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

Go Up