Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd (12, 11, 10, 9, 15, 16);
- bool flag = false;
- const int photoPin = A0;
- const int piezoPin = 8;
- const int SER = 5; // serial output to shift register
- const int LATCH = 6; // shift register latch pin
- const int CLK = 7; //shift register clock pin
- const int motionPin = 13;
- int val = 0;
- int pirState = LOW;
- int motion = 0;
- void setup()
- {
- pinMode (piezoPin, OUTPUT);
- pinMode (SER, OUTPUT);
- pinMode (LATCH, OUTPUT);
- pinMode (CLK, OUTPUT);
- digitalWrite (LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, B00000000);
- digitalWrite (LATCH, HIGH);
- delay (500);
- lcd.begin (16,2);
- lcd.print ( "Greetings" );
- lcd.setCursor (3,1);
- lcd.print ( "FAMILY");
- Serial.begin (9600);
- tone(piezoPin, 700);
- delay(30);
- noTone(piezoPin);
- }
- void loop()
- {
- val = digitalRead(motionPin);
- if (val == HIGH)
- { // check if the input is HIGH
- digitalWrite (LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, B11111111);
- digitalWrite (LATCH, HIGH);
- tone(piezoPin, 700);
- delay(500);
- noTone(piezoPin);
- lcd.clear();
- // we have just turned on
- lcd.println("Motion detected!");
- delay (500);
- // We only want to print on the output change, not state
- pirState = HIGH;
- }
- if (pirState == HIGH)
- {
- digitalWrite (LATCH, LOW);
- shiftOut(SER, CLK, MSBFIRST, B00000000);
- digitalWrite (LATCH, HIGH);
- lcd.clear();
- // we have just turned of
- lcd.println("Motion ended!");
- // We only want to print on the output change, not state
- pirState = LOW;
- delay (2000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement