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);
}
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.