Pages: [1] 2 3   Go Down
Author Topic: LCD help  (Read 3050 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright I attempted to search the forum but couldn't get an answer really.

I have a Duelmilanove wired up to a bread board.
In the bread board I have the 10K potentiometer and a 16x2 LCD I bought from Adafruit.


Using this pin set up and this code:

Code:
/*
  LiquidCrystal Library - Hello World
 
 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 "Hello World!" to the LCD
 and shows the time.
 
  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
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (*)
 example added 9 Jul 2009
 by Tom Igoe
 modified 25 July 2009
 by David A. Mellis

 */

// include the library code:
#include <LiquidCrystal.h>

// 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(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}


I have also added a 5V and GND for the back light.
(but of course this shouldn't matter or change anything what so ever)


Now for the problem..


I am getting the back light and I am able to control the contrast.
But I am not getting the "Hello World!".  :-/
Logged

Cairns, Australia
Offline Offline
Sr. Member
****
Karma: 2
Posts: 285
Arduino??
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A picture of your breadboard layout and connections would help greatly. Mixing up LCD pins is a very very common and easy to make mistake.

Does your sketch upload properly?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes it uploads just fine.
Currently I have it dismantled I will rebuild the setup again tomorrow.
(it's almost 1 AM here in NY)

I will upload pictures then.


Take note that I have rebuilt this three times today.
Logged

Spokane, Washington
Offline Offline
God Member
*****
Karma: 1
Posts: 686
My name is Bob, and I'm an addict.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm with Things on this one, I think the problem will be fixed when you rebuild it.

Another thing to check though, is the RW Pin (aka pin 5 on the LCD), with this setup on LiquidCrystal, the RW pin must be grounded (GROUND = WRITE)  since you're not able to read from HD47780 LCD's, no reason to be able to set the pin high to be able to "read".

So, put a jumper from GROUND to PIN5 on the LCD, it's just before Enable and just after RS.

I think that should do it!:D

EDIT:
I'm not sure if that's been pointed out or not, but I'm sure it'll be a fix in 0018! But regardless, it's something that should be mentioned right after the pin description.  And I know you said you're using the 10k potentiometer, but I read the example and it says "10k resistor, ends to 5v and ground"   lol... it's late... I read it like 5 times before realizing it was suppose to be a potentiometer.
« Last Edit: November 12, 2009, 04:52:38 am by thoed » Logged

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

vampist:

You are displaying the message "hello, world!" in setup(), which is correct -
BUT
You immediately proceed to loop() where you immediately cover up the message with the first millis() count
AND
You are immediately covering that count with the next, etc. etc. etc

You need a delay at the end of setup() which will let you read the "hello, world!" message.  You also need a delay within loop() which will give you time to read a millis() value before it is covered up with the next one.

You could probably get by with just one delay, at the beginning of loop() .

Don
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you everyone who has replied, I will be rebuilding this as soon as I get home tonight.

Are you sure I should put a delay after the lcd.print in the setup loop?

I may just put this code in and see if it works.

Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
  lcd.begin(16, 2);
  lcd.print("hello, world!");
}
void loop() {
digitalWrite(13, HIGH);
delay(250);
digitalWrite(13, LOW);
delay(1000);
}


Does this code look good to everyone?
Therefore there is no rewrite to the lcd after "hello world!".
Only change after is the pin 13 light should flash.


EDIT: Heck for good measure I could even throw a delay() in the setup.

By the way that was the release code under examples.
« Last Edit: November 12, 2009, 01:09:40 pm by vampist » Logged

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

Code:
By the way that was the release code under examples.
No.  The example program has an empty loop() function so that the "hello, world!" message is not immediately covered up as yours was (or would be if everything else is ok).
 
Don
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm having similar problems with the same example.  I'm using a Mega with a 4x20, both from adafruit.  I've rebuild the breadboard three times.  The back light comes on and I can adjust the contrast, voltages on pins 2 and 3 make sense.

The example with the milliseconds display came from the 0017 examples.  the example with a void loop {} came from the tutorial.

Maybe someone who is experienced could please double check to make sure the various versions of 'helloworld' work?  I can't tell if it is the display or the software, although it's probably the keyboard to chair interface....

Thanks for taking care of a couple of newbies!

Rich.
Logged

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

oops - I overlooked the setCursor which puts the millisecond display on the second row.

I'll build this up later this evening and get back to you.

Don
« Last Edit: November 12, 2009, 05:59:47 pm by floresta » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for taking the time to check this out!  

There are several examples out there, with .cpp and .h files to go with them.  Is there some special way to keep the .pde, .cpp, and .h files under control?  put them all in arduino-0017\hardware\libraries?  When it compiles an example, how does it know where to look for the .cpp and .h files?  What's your method/technique that works?

Thanks,  Rich.
Logged

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

Well it works for me.  Here's what I did.

First I connected just the power and the contrast and verified that I got a blank screen with the pot set to one end and a row of dark boxes on the top row with the pot set to the other end.  I readjusted the pot until the row of boxes was barely visible.

Next I built up the rest of the circuit.  I used the description of the connections given in the comments.  I also made sure to ground pin 5, the R/W pin.   You may have missed this key step.

I downloaded a pristine copy of Arduino v0017, unzipped the archive and created a shortcut to arduino.exe.

I opened the IDE and cut and pasted the program code from the original post into the blank sketch.

I did a verify followed by an upload and got the "hello, world!" message on the top row and a incrementing count on the second row.

Don




Logged

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

Update -

I added this code to loop()

digitalWrite(13, HIGH);
delay(250);
digitalWrite(13, LOW);
delay(1000);


and now the LED on pin 13 flashes as well.

Don
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

VDD pin is 5V correct?
Logged

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

Quote
VDD pin is 5V correct?
Yes

Don
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool!  I'll try to do exactly what you said, tomorrow.  and I'll post the results.  

Another exciting adventure!

Thanks,  Rich.
Logged

Pages: [1] 2 3   Go Up
Jump to: