I am new to the arduino. I was making a portable weather station with and arduino NANO, DHT 11 temp and humidity sensor, and a 16 X 2 LCD. after i made the circuit I plugged it into the computer and everything was working as I intended it to but after I plugged it in the second time the LCD contrast stopped working and it stopped displaying text.
At first I thought I might have made a wrong connection; so I made another circuit with the UNO, LCD, and a 10K potentiometer; the problem was still there.
I tried it over again with two more 16 X 2 LCD's but the problem still continued.
I tried it with the I2C module and the contrast started working with the in built potentiometer. Then i thought the problem was with the arduino software so i deleted it and reinstalled it but the problem still continued. I tried with two arduino UNO's and one arduino NANO but nothing seems to be solving the problem.
does anyone know the solution??
thank you.
#include <LiquidCrystal.h>
int rs = 7;
int en = 8;
int d4 = 9;
int d5 = 10;
int d6 = 11;
int d7 = 12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int dt = 1000;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
}
void loop() {
// put your main code here, to run repeatedly:
lcd.setCursor(0, 0);
lcd.print("Hello World");
lcd.setCursor(0, 1);
lcd.print("I am Alive");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Watch me count");
for (int j = 0; j <= 10; j+=1){
lcd.setCursor(0, 1);
lcd.print(j);
delay(1000);
}
lcd.clear();
}
Your breadboard seems to have the power rails broken in the middle. Put jumpers there. You need ground for the contrast pot (but not Vcc, see below).
Almost all of the LCD tutorials have the wiring of the contrast pot wrong. It is a mistake that has been perpetuated through the years. The right way is to wire the one end of the pot to ground and the wiper to LCD pin 3 (V0). The other end of the pot is left disconnected. So the pot is a variable resistor. Actually I find that a 1K fixed resistor from ground to Vo gives me satisfactory contrast on virtually every LCD that I have tried.
yes the Code is the same. the only thing I changed was the potentiometer connection. I hooked up two potentiometer pins instead of three; one which connects to GND and the center one which connects to the contrast pin (V0; third pin from the right).
No, that is the point.
Not only do you not need to connect all three pins of the potentiometer, but that makes contrast setting much more difficult and wastes current which may not matter if using a mains supply, but does if using batteries.
And the proper variable resistor value is 1k. If you are experimenting with a 10k potentiometer, it actually works well to connect both ends to ground!