Use a 1602 LCD Display - How to Arduino #2

16,018

34

7

Introduction: Use a 1602 LCD Display - How to Arduino #2

About: Electronics are a newly re-found hobby for me. I'm not an engineer - I'm an ordinary guy who likes to tinker with electronics in his free time. You can see more about my projects at www.meanpc.com.

How to use a standard 16X2 LCD with the Arduino

Be the First to Share

    Recommendations

    • Arduino Contest

      Arduino Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Toys & Games Contest

      Toys & Games Contest

    7 Comments

    0
    meanpc
    meanpc

    5 years ago

    Comment out anything that doesnt have to do with the LCD then get the LCD working. That way you know you don't have more than one dragon to slay.

    0
    meanpc
    meanpc

    5 years ago

    Your code looks fine to me, can't really help any more without a picture.

    0
    vandenbrande
    vandenbrande

    5 years ago

    Hi,

    I am making a soil hygrometer, but i wanna print it to LCD, i am new to arduino actualy this is my second thing im doing. The LCD Lights up in blue and i can see white pixels in blocks... the hygrometer works and its in a glass measuring doing its job like it should as i can see in the serial monitor, but my lcd is not doing getting any digits just blocks.. when i add a delay in void loop then i see some flickering on the lcd everytime the hygrometer measures and sends it to the serial monitor.. how can i build this correctly?

    #include <LiquidCrystal.h>

    int soil=0;

    int SensorPin = A1;

    int SensorValue;

    int pinNumber = 2;

    LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

    void setup() {

    // read the input on analog pin 0:

    int sensorValue = analogRead(A0);

    sensorValue = constrain(sensorValue, 485, 1023);

    // print out the value you read:

    //Serial.println(sensorValue);

    //map the value to a percentage

    soil = map(sensorValue, 485, 1023, 112, 0);

    // print out the soil water percentage you calculated:

    Serial.print(soil);

    Serial.println(sensorValue);

    Serial.begin(9600);

    delay(1000);

    //////////////////////////////////////

    pinMode(pinNumber, OUTPUT);

    pinMode(SensorPin, INPUT);

    lcd.begin(16, 2);

    lcd.print(" dendans soil ");

    lcd.setCursor(0,1);

    lcd.print("moisture sensor ");

    delay(5000);

    lcd.clear();

    lcd.setCursor(0,0);

    lcd.print("High value = dry" );

    lcd.setCursor(0,1);

    lcd.print("Low value = wet");

    delay(3000);

    lcd.clear();

    lcd.print(" optimum value");

    lcd.setCursor(0,1);

    lcd.print(" > 35------65 <");

    delay(3000);

    lcd.clear();

    Serial.begin(9600);

    Serial.print("soil moisture sensor");

    }

    void loop() {

    int sensorValue = analogRead(A0); Serial.println(sensorValue);

    SensorValue = analogRead(SensorPin);

    lcd.setCursor(0,0);

    lcd.print(" moisture value ");

    lcd.setCursor(0,1);

    lcd.print("testest");

    lcd.print(SensorValue/10.3);

    lcd.setCursor(0,1);

    lcd.clear();

    lcd.setCursor(0,1);

    lcd.print(SensorValue/10.3);

    if(analogRead(1)>901 && analogRead(1)< 1023)

    {lcd.print(" Not in use");}

    if(analogRead(1)>701 && analogRead(1)< 900)

    {lcd.print(" : dead dry");}

    if(analogRead(1)>(601) && analogRead(1)< 700)

    {lcd.print(" : too dry");}

    if(analogRead(1)>350 && analogRead(1)< 600)

    {lcd.print(" : perfect");}

    if(analogRead(1)>201 && analogRead(1)< 349)

    {lcd.print(" : too wet");}

    if(analogRead(1)<200)

    {lcd.print(" : drowning");}

    }

    0
    meanpc
    meanpc

    Reply 5 years ago

    If you get back to me on the contrast and that doesn't work I will then check out your code. It really sounds like contrast though. Have you made a "Hello World" type run on that LCD yet?

    0
    vandenbrande
    vandenbrande

    Reply 5 years ago

    Ok im gonna figure it out now, at least try. and the contrast works fine.

    with potentiometer.

    0
    meanpc
    meanpc

    Reply 5 years ago

    First thing - have you tried adjusting the contrast? At one end of the contrast scale, you won't see anything, at the other end you will just see white blocks.

    0
    vandenbrande
    vandenbrande

    Reply 5 years ago

    Yes that works fine with the potentiometer, but its just not printing the data from the hygrometer to the lcd, i need this project pretty soon.