Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

4x20 LCD: Only 2 Lines Work
Moderators: adafruit_support_bill, adafruit

4x20 LCD: Only 2 Lines Work

by dww on Wed Jan 23, 2013 2:38 pm

Hello,

This is my first post and I'm quite new to Arduino. I've got a 4x20 RBG LCD and I've followed the LCD tutorial, but it only help me get 2 lines of my 4x20 LCD to work.

This is a guess, but I'm thinking that there must be something that requires changing in the LiquidCrystal.h library so that I can get all 4 lines to work?

If you have any suggestions, please let me know.


===
DancesWithWords

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm

Re: 4x20 LCD: Only 2 Lines Work

by adafruit_support_bill on Wed Jan 23, 2013 2:46 pm

In setup(), change lcd.begin(16, 2); to lcd.begin(20, 4);
Code: Select all | TOGGLE FULL SIZE
void setup() {
  // set up the LCD's number of rows and columns:
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

adafruit_support_bill
 
Posts: 37483
Joined: Sat Feb 07, 2009 10:11 am

Re: 4x20 LCD: Only 2 Lines Work

by dww on Wed Jan 23, 2013 3:49 pm

Tried your solution and received:

sketch_jan22a.cpp: In function ‘void setup()’:
sketch_jan22a.cpp:7:3: error: ‘lcd’ was not declared in this scope



===
DancesWithWords

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm

Re: 4x20 LCD: Only 2 Lines Work

by adafruit_support_bill on Thu Jan 24, 2013 6:20 am

What name did you use for your liquid crystal object?
If you declared
Code: Select all | TOGGLE FULL SIZE
LiquidCrystal xxxxx(12, 11, 5, 4, 3, 2);


Then you call
Code: Select all | TOGGLE FULL SIZE
xxxxx.begin(20, 4)


in your setup()

adafruit_support_bill
 
Posts: 37483
Joined: Sat Feb 07, 2009 10:11 am

Re: 4x20 LCD: Only 2 Lines Work

by dww on Thu Jan 24, 2013 12:25 pm

I got the LCD working with the following:

Code: Select all | TOGGLE FULL SIZE
#include <LiquidCrystal.h>

/*
 LiquidCrystal display with:
 LCD 1 (0V) to arduino ground pin 14
 LCD 2 (5V) to arduino +5 V
 LCD 3 (V0) to output from potentiometer 10kOhm connected between +5 V and GND
 LCD 4 (RS) to arduino pin 12
 LCD 5 (R/W) to arduino ground
 LCD 6 (E) to arduino pin 11
 LCD 11 (DB4), 12 (DB5), 13 (DB6), 14 (DB7) on arduino pins 7, 8, 9, 10
 LCD15 (LED+) through resistor 12 Ohm to arduino +5 V
 LCD16 (LED-) to arduino ground
 */

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

void setup()
{
  lcd.begin(20, 4); //lcd.begin(columns, rows)
  lcd.setCursor(2,0); // Position cursor on line x=3,y=1
  lcd.print("4x20 LCD DISPLAY"); // Print a message to the LCD
  lcd.setCursor(3,1);
  lcd.print("with controller");
  lcd.setCursor(7,2);
  lcd.print("HD44780");
  lcd.setCursor(1,3);
  lcd.print("useful for Arduino");
}

void loop()
{
}



I was wondering how does one do a scrolling message?

===
DWW

PS. Really appreciate the prompt help.
Last edited by franklin97355 on Mon Nov 17, 2014 2:38 am, edited 1 time in total.
Reason: Changed quote to code in tags

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm

Re: 4x20 LCD: Only 2 Lines Work

by adafruit_support_bill on Thu Jan 24, 2013 3:04 pm

There is an "Autoscroll" example sketch in the LiquidCrystal library examples.

adafruit_support_bill
 
Posts: 37483
Joined: Sat Feb 07, 2009 10:11 am

Re: 4x20 LCD: Only 2 Lines Work

by dww on Mon Nov 17, 2014 1:05 am

Thanks for the Autoscroll. I'm working on a new feature of this RGB LCD and that is to get the colour to rotate. I'm using your sketch from: https://learn.adafruit.com/character-lcds?view=all, but that only get me the message, not the rotating colours.
I've noticed that this LCD (WH2004A) has 18 pins and that the last 3 (pin 16 red, 17 green, 18 blue) control the colours. Am I right about that?

I thought if I changed:
#define REDLITE 3
#define GREENLITE 5
#define BLUELITE 6

to

#define REDLITE 16
#define GREENLITE 17
#define BLUELITE 18

That would fix my problem, but it did not? Could you suggest a solution? Thanks


===
DancesWithwords

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm

Re: 4x20 LCD: Only 2 Lines Work

by adafruit_support_bill on Mon Nov 17, 2014 7:34 am

Post a photo showing your wiring. Use the example code as-is. You will need jumpers from Arduino pins 3, 5 and 6 to LCD pins 16, 17 and 18.

adafruit_support_bill
 
Posts: 37483
Joined: Sat Feb 07, 2009 10:11 am

Re: 4x20 LCD: Only 2 Lines Work

by dww on Mon Nov 17, 2014 10:36 am

Is there a restriction on image size for upload? Mine are being rejected as invalid?

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm

Re: 4x20 LCD: Only 2 Lines Work

by dww on Mon Nov 17, 2014 10:59 am

This are my pic's of the set before any changes to pinning where done.

20141117_082550sm.jpg
20141117_082550sm.jpg (48.51 KiB) Viewed 197 times
20141117_082515sm.jpg
20141117_082515sm.jpg (55.35 KiB) Viewed 197 times

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm

Re: 4x20 LCD: Only 2 Lines Work

by adafruit_support_bill on Mon Nov 17, 2014 11:08 am

There is a 1 meg limit for posting photos. 800x600 is a good size.
For the example sketch to work, you need jumpers from Arduino pins 3, 5 and 6 to LCD pins 16, 17 and 18.

adafruit_support_bill
 
Posts: 37483
Joined: Sat Feb 07, 2009 10:11 am

Re: 4x20 LCD: Only 2 Lines Work

by dww on Mon Nov 17, 2014 11:15 am

Tried that pinning and I see no change in colours though I do get the a display.


--
DWW

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm

Re: 4x20 LCD: Only 2 Lines Work

by adafruit_support_bill on Mon Nov 17, 2014 11:48 am

Please post a photo showing your wiring and the exact code you are using.

adafruit_support_bill
 
Posts: 37483
Joined: Sat Feb 07, 2009 10:11 am

Re: 4x20 LCD: Only 2 Lines Work

by dww on Mon Nov 17, 2014 11:57 am

THE CODE:


Code: Select all | TOGGLE FULL SIZE
// include the library code:
#include <LiquidCrystal.h>
#include <Wire.h>
 
#define REDLITE 3
#define GREENLITE 5
#define BLUELITE 6
 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
 
// you can change the overall brightness by range 0 -> 255
int brightness = 255;
 
void setup() {
  // set up the LCD's number of rows and columns:
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.print("RGB 16x2 Display  ");
  lcd.setCursor(0,1);
  lcd.print(" Multicolor LCD ");
 
  pinMode(REDLITE, OUTPUT);
  pinMode(GREENLITE, OUTPUT);
  pinMode(BLUELITE, OUTPUT);
 
  brightness = 100;
}
 
 
void loop() {
  for (int i = 0; i < 255; i++) {
    setBacklight(i, 0, 255-i);
    delay(5);
  }
  for (int i = 0; i < 255; i++) {
    setBacklight(255-i, i, 0);
    delay(5);
  }
  for (int i = 0; i < 255; i++) {
    setBacklight(0, 255-i, i);
    delay(5);
  }
}
 
 
 
void setBacklight(uint8_t r, uint8_t g, uint8_t b) {
  // normalize the red LED - its brighter than the rest!
  r = map(r, 0, 255, 0, 100);
  g = map(g, 0, 255, 0, 150);
 
  r = map(r, 0, 255, 0, brightness);
  g = map(g, 0, 255, 0, brightness);
  b = map(b, 0, 255, 0, brightness);
 
  // common anode so invert!
  r = map(r, 0, 255, 255, 0);
  g = map(g, 0, 255, 255, 0);
  b = map(b, 0, 255, 255, 0);
  Serial.print("R = "); Serial.print(r, DEC);
  Serial.print(" G = "); Serial.print(g, DEC);
  Serial.print(" B = "); Serial.println(b, DEC);
  analogWrite(REDLITE, r);
  analogWrite(GREENLITE, g);
  analogWrite(BLUELITE, b);
}
Last edited by adafruit_support_bill on Mon Nov 17, 2014 12:14 pm, edited 1 time in total.
Reason: Fixed [code] tags

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm

Re: 4x20 LCD: Only 2 Lines Work

by dww on Mon Nov 17, 2014 12:36 pm

These two pics are with the pins 3,5,6 connected to 16,17,18


20141117_105112sm.jpg
20141117_105112sm.jpg (55.22 KiB) Viewed 173 times
20141117_105553sm.jpg
20141117_105553sm.jpg (55.13 KiB) Viewed 173 times

dww
 
Posts: 33
Joined: Thu Nov 29, 2012 4:43 pm