Go Down

Topic: LCD4Bit for 20x4 displays! (Read 8 times) previous topic - next topic

GekoCH

hmm one question:
I always get this error after compiling:
Couldn't determine program size:

What's the matter?

cheers
Geko

billyboy

you forgot to show your error, but maybe this helps. I had errors to when compiling. The reason was that i had more liberies to control the lcd in the libary directory that use the same files.
Try to tempery move other libs and try again.

I hope this hepls you.

GekoCH

#17
Aug 19, 2008, 07:59 am Last Edit: Aug 19, 2008, 08:03 am by GekoCH Reason: 1
hmm that worked!

Ok but now as I uploaded the sketch nothing
appears on the screen.

Hmm could you pls send me your library and sketch...
I think I messed it up...

PS: The Display shows:


Geko

billyboy

Quote
hmm that worked!

Hmm could you pls send me your library and sketch...
I think I messed it up...
Geko


This evenig i wil send it to you when i'am home.

billyboy


GekoCH

#20
Aug 19, 2008, 08:59 pm Last Edit: Aug 19, 2008, 09:03 pm by GekoCH Reason: 1
thx a lot.
I'm gonna try this...

Geko

GekoCH

ok great your code works for a 4x20 Display
It does work on my 4x40 Display but of course it
does show the second line on the first line just 20
characters to the right :)

So I changed your cpp to:
Code: [Select]
void LCD4Bit::cursorTo(int line_num, int x){
 //first, put cursor home
 commandWrite(CMD_HOME);
 if (x>39)
 {
       x=39;
 }
switch (line_num)
 {
case 1:
   x+=0x00 ; break;
 case 2:
   x+= 0x80 ; break;
 case 3:
   x+= 0x28 ; break; // In fact, line 3 is an extension of the line 1 (beyond the 20 first characters)
 case 4:
   x+= 0xa8 ; break; // Line 4 is an extension of line 2
 }
 //
 commandWrite(0x80+x);
}


but it does not work. Could you help me pls....

Geko

billyboy

#22
Aug 20, 2008, 08:36 pm Last Edit: Aug 20, 2008, 08:39 pm by billyboy Reason: 1
My quistion to you is, don't you have 2 enable pins on you LCD?
in that case look at the repost in this trat Reply #7 from legba7


Else, tray to play with the x e.d. : x+= 0x80 ,0x14 0x54

I don't have your LCD so i can't try.

Good luck, and let us no if it works and with what values.

GekoCH

Yes I know I posted this link put it does not work for my LCD.
Nothing appears the LCD is just empty....

Phu that's a hard nut....

Geko

Bjonnh

Here it is: http://bjonnh.free.fr/LCD4Bit.zip This is the old version, I'm using this one for now (an urgent project to do)

GekoCH

Quote
Here it is: http://bjonnh.free.fr/LCD4Bit.zip This is the old version, I'm using this one for now (an urgent project to do)

so do you have a 4x40 Display running with this code?
Hmm mine does not work. I got 2 Enable signals so I
could just connect one of them...

Thx
geko

GordonEndersby


Hi, I was looking for something like this and it works for me on an mtc-c204dply-1n 4x20 lcd display with 1 enable pin.

Gordon

Stormrider

#27
Oct 15, 2008, 11:30 am Last Edit: Oct 15, 2008, 11:55 am by Stormrider Reason: 1
I'm stuck! I can't get any text to display, and it seems to be hanging up somewhere since the debug LED never goes off.

I'm using a WH2004A 4x20 with the KS0066 driver.

I'm at a loss at what to do, any ideas?

*edit*

A bit of an update. I'm fairly sure that the Freeduino is talking to the LCD, since the lcd.clear command is working. Also, I inserted a small debug script for the LED, it blinks once for the first command, twice for the second ect. It's not just staying on anymore, it's blinking like it's supposed to (the LED) but I still don't have any text output on the display. Here's the code I've been using, any suggestions?


//example use of LCD4Bit library

#include <LCD4Bit.h>
//create object to control an LCD.  
//number of lines in display=1
LCD4Bit lcd = LCD4Bit(4);



void setup() {
 pinMode(13, OUTPUT);  //we'll use the debug LED to output a heartbeat

 lcd.init();
 //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
 //lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)

}

void loop() {  
 digitalWrite(13, HIGH);  //light the debug LED
 delay(200);
 digitalWrite(13, LOW);
 delay(1000);
 
 //lcd.clear();
 digitalWrite(13, HIGH);  //debug lcd.clear
 delay(200);  
 digitalWrite(13, LOW);
 delay(1000);
 
 lcd.cursorTo(1,0);
 lcd.printIn("Line 1");
 digitalWrite(13, HIGH); //debug first line of print
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(1000);
 
 lcd.cursorTo(2,0);
 lcd.printIn("Line 2");
 digitalWrite(13, HIGH); // debug second line
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(1000);

 
 lcd.cursorTo(3,0);
 lcd.printIn("Line 3");
 digitalWrite(13, HIGH);  //debug third line
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(1000);
 
 lcd.cursorTo(4,0);
 lcd.printIn("Line 4");
 digitalWrite(13, HIGH);  //debug fourth line
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(200);
 digitalWrite(13, HIGH);
 delay(200);
 digitalWrite(13, LOW);
 delay(1000);
 
 
 delay(1000);
 digitalWrite(13, HIGH);
 delay(1000);
 digitalWrite(13, LOW);  //end debug LED

}



*another edit*

Yes I did comment out the lcd.clear command on purpose, just to see if it was clearing the 2 lines of blocks when I powered it up, and yes it does, if it's commented out, the blocks stay on the screen.

*yet another edit*

Ok, for some reason, when the cursor goes to line 3, the blocks dissapear. I'm guessing that there's no problem in communication, as things are happening, it's just that I'm getting no text output on the screen.

GuoHui

Hi,

I am using the code below to write user-defined code, but it is not working. I am using HD44780 4x20 LCD module.

Quote
void LCD4Bit::WriteCGRAM(int adress, char code[]) {
  commandWrite(0x40+(adress<<3));

  for (int i=0 ; i <= 7 ; i++)
       {
               print(code);
       }
  commandWrite(CMD_HOME);
}

FrankRadio

Hi all!
I'm using to a 4x20 LCD a wintec 2004.

Now i have it working and what i note in it is this, to print the complete scren needs a little bit time   :'(, so what i do is minimize all the delays() inside the lcd4bit lib.

Now works great, but what will be nice is send the complete screen and then turn on the display, i meen charge it first and then show the text. :o

Can be done? using what cmd ? ;D

Best Regads
Frank

Go Up