I wrote a code for ADC using analog voltage read and LCD. As follows:-
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //(RS,en,D4,D5,D6,D7)
int voltpin=A0;
int voltage;
void setup()
{
pinMode(voltpin,INPUT);
lcd.begin(16, 2);
}
void loop()
{
analogRead(voltpin);
lcd.setCursor(0,0);
lcd.print("Device Active");
lcd.setCursor(0,2);
if(analogRead(voltpin)>=1)
{
lcd.print("DETECTED");
}
if(analogRead(voltpin)<1)
{
lcd.print("NOT DETECTED");
}
}
The code works as it should on Proteus but when I am connecting my LCD(JHD162a) in reality to Arduino Uno nothing is being displayed on the display only the backlight is turning on.
Is there something wrong with my code or am i interfacing the lcd wrong ?
LCD connections are as follows:-
Pin 1 - Ground
Pin 2- +5v
Pin 3- Ground
Pin 4- Digital pin 12
Pin 5- Ground
Pin 6- Digital pin 11
D4, D5, D6, D7 to D5, D4, D3, D2 of the arduino respectively.
I adjusted the contrast using resistors and there were changes in contrast but display still remains blank. Also tried making RW pin high as in data sheet but same result.