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
4x20 LCD: Only 2 Lines Work
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: 4x20 LCD: Only 2 Lines Work
In setup(), change lcd.begin(16, 2); to lcd.begin(20, 4);
Code: Select all
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!");
}
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
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
sketch_jan22a.cpp: In function ‘void setup()’:
sketch_jan22a.cpp:7:3: error: ‘lcd’ was not declared in this scope
===
DancesWithWords
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: 4x20 LCD: Only 2 Lines Work
What name did you use for your liquid crystal object?
If you declared
Then you call
in your setup()
If you declared
Code: Select all
LiquidCrystal xxxxx(12, 11, 5, 4, 3, 2);
Code: Select all
xxxxx.begin(20, 4)
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
I got the LCD working with the following:
I was wondering how does one do a scrolling message?
===
DWW
PS. Really appreciate the prompt help.
Code: Select all
#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
Reason: Changed quote to code in tags
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: 4x20 LCD: Only 2 Lines Work
There is an "Autoscroll" example sketch in the LiquidCrystal library examples.
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
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
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
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: 4x20 LCD: Only 2 Lines Work
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.
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
Is there a restriction on image size for upload? Mine are being rejected as invalid?
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
This are my pic's of the set before any changes to pinning where done.
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: 4x20 LCD: Only 2 Lines Work
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.
For the example sketch to work, you need jumpers from Arduino pins 3, 5 and 6 to LCD pins 16, 17 and 18.
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
Tried that pinning and I see no change in colours though I do get the a display.
--
DWW
--
DWW
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: 4x20 LCD: Only 2 Lines Work
Please post a photo showing your wiring and the exact code you are using.
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
THE CODE:
Code: Select all
// 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
Reason: Fixed [code] tags
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
These two pics are with the pins 3,5,6 connected to 16,17,18
Please be positive and constructive with your questions and comments.