LCD Not Working

I am trying to create a motion sensor that lights up an LED, sounds a buzzer, and displays a message on the LCD when there is motion or no motion detected. However, currently the LCD only turns on but does not display anything else.

// C++ code
#include <LiquidCrystal.h>

int ledPin = 13;
int pirPin = 2;
int pirStat = LOW;
int buzzPin = 7;

// Do not delete d6 or d7
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 6;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);
  lcd.display();
  lcd.begin(16, 2);
}

void loop()
{
  pirStat = digitalRead(pirPin);
  digitalWrite(buzzPin, LOW);
  noTone(buzzPin);
  if (pirStat == HIGH) {
    lcd.print("Motion");
    Serial.println("Motion");
    digitalWrite(ledPin, HIGH);
    digitalWrite(buzzPin, HIGH);
    tone(buzzPin, 1000); 
    delay(20);
  } 
 
  else
  {  
    lcd.print("No Motion");
    digitalWrite(ledPin, LOW);
    digitalWrite(buzzPin, LOW);
    noTone(buzzPin);
    Serial.println("0");
  }
  //lcd.setCursor (9,1);   
 
  // Turn on the display:
  //lcd.display();
  //delay(1000);     
}


Welcome to the forum

Can you display a message on the LCD using a simple "Hello World" sketch ?

Do the examples that came with the LVD library work ?

I modified the setup() function to include lcd.print("Hello World") on the last line, however, nothing appeared.

Posting an annotated schematic would help, I do not read frizzy, on my system it is not clear enough to follow.


Sorry I hope this is better. I am relatively new to Arduino.

It appears your contrast pot is to high in value. Without looking I believe it should be less than 20K. Also I do not see a VCC connection to the display. That would allow it to light up but not display any characters.

There are no power connected to the display.
If the image with the bredboard shows your wiring correct, I can't see any power
wires to the lower two rows on the bredboard - it should be your power.

Your sketch pins do not match your drawing to the LCD.. also... ouch (probably just a typeo).
yikes

The potentiometer should be connected between Vo and GND.

Your fritzing mess shows that it will be correctly connected once the horizontal bus is connected to GND) .

Your schematic shows the potentiometer between Vo and Vcc, also Vcc isn't connected to 5v as mentioned previously.

To get started just remove the potentiometer completely and connect Vo to GND.

Don

@xfpd -

Your comment is correct however that connection will actually work.

Don

Yes, I am learning why it is correct. I had been doing that wrong. Sorry.

None of the drawings show a connection to the R/W pin.
That needs to be grounded.

--- bill

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.