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: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: 4x20 LCD: Only 2 Lines Work
I see one green wire going to either pin 2 or pin 3. Then a blue wire going to pin 8. I can't tell where the other ends of those wires are going. but there is nothing visibly connected to pins 5 or 6 on your arduino.
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
So there is the problem. Sorry when you previously stated that I needed to jumper to 3,6,7 to 16,17,18 I thought you meant to the pins on the LCD... DOH!
So now it is working.
Now we have solved that problem I will move on to the next task on my list. I what to take a sketch I all ready have that does temperature, humidity and dew point (haven't got a sketch for dew point, but I'll find one that I can integrate) and have ranges of temperatures reflected it colour. i.e. anything under 15 degrees Celsius to be blue, 15 to 25 Celsius in green and over 25 Celsius to be red. As an added bonus at temperatures of +/- 30 for the screen to blink on/off.
So now it is working.
Now we have solved that problem I will move on to the next task on my list. I what to take a sketch I all ready have that does temperature, humidity and dew point (haven't got a sketch for dew point, but I'll find one that I can integrate) and have ranges of temperatures reflected it colour. i.e. anything under 15 degrees Celsius to be blue, 15 to 25 Celsius in green and over 25 Celsius to be red. As an added bonus at temperatures of +/- 30 for the screen to blink on/off.
- dww
- Posts: 47
- Joined: Thu Nov 29, 2012 4:43 pm
Re: 4x20 LCD: Only 2 Lines Work
In case anyone is interested this is my final working sketch. It more or less centre things nicely on the first and second rows.
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.setCursor(2,0);
lcd.print("RGB 20x4 Display ");
lcd.setCursor(2,2);
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 1:15 pm, edited 1 time in total.
Reason: Fixed [code] tags
Reason: Fixed [code] tags
Please be positive and constructive with your questions and comments.