Pages: [1]   Go Down
Author Topic: LCD has strange characters when not lcd.clear() is sent  (Read 2251 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a 2x20 LCD display type LM032L with HD44780A chip.
This display has no backlight.

When i send text to the display it is only displayed when there is a lcd.clear();
before the text line.
When the second message is send i see only trange characters, when i put again a lcd.clear before the message it is displayed alright.

I have send the software code for photoduino to the Arduino one v3, and there it is the same, but i cannot put everywhere in the code this lcd.clear() command.

Does anybody know what i can do about this?
Maybe a hardware issue?
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does anybody know what i can do about this?
Without seeing your code we would only be guessing.

Quote
I have send the software code for photoduino to the Arduino one v3, and there it is the same, but i cannot put everywhere in the code this lcd.clear() command.
I think you may be using Google translate or something similar.  Try rephrasing this and run it through the translator again.

Don
« Last Edit: December 23, 2011, 02:57:14 pm by floresta » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I Think it is not in the code, but in the hardware (LCD display)

This problem is with every code that send the line  lcd.print("Hello, World");

Code:
  lcd.begin(20,2);           
  lcd.clear();                 
  lcd.setCursor(0,0);       
  lcd.print("Hello, World");

If there is not the line with lcd.clear();
Then i have strange characters.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You do not need the lcd.clear() or the lcd.setCursor(0,0) since both functions are taken care of by the lcd.begin() function.

You did not post your entire sketch.  Was that code in setup() or in loop()?

Try this sketch:

Code:
...
void setup()
  {
  lcd.begin(20, 2);
  lcd.print("hello, world!");
  lcd.setCursor(0,1)
  lcd.print("it works!");
  }

void loop()
  {
  }

Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It happens with every code i use from the examples.

Code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(20,2);
 }

void loop() {
  // set the cursor to (0,0):
  lcd.setCursor(0, 0);
  // print from 0 to 9:
  for (int thisChar = 0; thisChar < 10; thisChar++) {
   lcd.print(thisChar);
   delay(500);
  }

  // set the cursor to (16,1):
  lcd.setCursor(16,1);
  // set the display to automatically scroll:
  lcd.autoscroll();
  // print from 0 to 9:
  for (int thisChar = 0; thisChar < 10; thisChar++) {
    lcd.print(thisChar);
    delay(500);
  }
  // turn off automatic scrolling
  lcd.noAutoscroll();
 
  // clear screen for the next loop:
  lcd.clear();
}

when i send this code to the arduino, i get rubish.
When i insert lcd.clear(); after lcd.begin(20,2); then it is al working.
This happend with every code

I spend hours to this, and i don't understand it.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you try the sketch that I posted for you?

Did you notice that loop() is empty in my sketch?  You do not want to send unchanging information to the LCD over and over again which is what you are doing. 


Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Floresta,

Yes i have tried your code.
but first.

I have now an other display, the same type.
This one is better, not that much strange characters, but now i am missing the first character on the first line.

With you code i am missing the first character too.

"ello world!"
"it works!"

Mabey it is the type of display
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Mabey it is the type of display
That is really the only explanation since I know that the code is correct and we also know that your wiring is correct since most of the message is displayed correctly.  Some of the bargain displays being sold are probably ones that don't quite meet the factory specs.

It looks like your display may be taking too long to complete the commands in the lcd.begin() function so it is missing the first letter sent to it by the lcd.print() function.  You could stick a 10 mS delay in before the lcd.print() function and see if that helps.


Don
Logged

Greenwood, Indiana
Offline Offline
God Member
*****
Karma: 0
Posts: 508
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have this which does not match the example code or wiring.

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

When I tried to run your code it caused garbage. My LCD is wired per the example and when I changed your code to match it worked.
Logged

If it was designed by man it can be repaired by man.

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You have this which does not match the example code or wiring.

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

There is nothing sacred about the pins used in the example.  It is, however, important to make sure that the code matches the wiring which is why we frequently ask for both the code and a photograph of the wiring when troubleshooting. 

Did you read reply #7?  Since he does get a valid display some of the time we know that his wiring does match his code so the problem must be elsewhere else.


Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have put a delay of 10ms in front of a lcd.print, and dthat does the trick.
The first charachter is now printed.

But in the code for photoduino, there are a lot of lcd.print orders.
Do i now have to put in every cas the delay function?

Or can i make 1 code for all?
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have put a delay of 10ms in front of a lcd.print, and dthat does the trick.
The first charachter is now printed.
Now you can experiment with shorter delays to find out just how long a delay is required.

Quote
But in the code for photoduino, there are a lot of lcd.print orders.
Do i now have to put in every cas the delay function?
You will have to experiment in order to determine the answer.  Most likely it will depend on what was previously sent to the LCD controller which will most likely not always be the same.

Quote
Or can i make 1 code for all?
If this is the case then you might want to consider creating a new function that includes both the delay and the print.

Don
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I shall try to make an funtion. smiley

Thans for your answers
Logged

Pages: [1]   Go Up
Jump to: