PIR Motion Sensor and16x2 I2C LCD Display with Arduino | English Subtitle
ฝัง
- เผยแพร่เมื่อ 15 ธ.ค. 2023
- If you need any custom code for your projects, please contact me on Skype- G B RANJITKAR (message only/no calls) Not free, there will be a fee.
PIR Motion Sensor and16x2 I2C LCD Display with Arduino | English Subtitle
#robot #robotics #engineering #education #educational #school #college #learning #code #coading #diy
Code : code is on the comment below.
Facebook : / doit20-104218935882053
Please Subscribe my Channel. ThankYou!
#include
#include
int pirSensorPin = 2;
int ledPin = 13;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
pinMode(pirSensorPin, INPUT);
pinMode(ledPin, OUTPUT);
lcd.init(); // initialize the LCD
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print(" PIR ");
lcd.setCursor(0, 1);
lcd.print(" Motion Sensor ");
delay(3000);
lcd.clear();
Serial.begin(9600);
}
void loop() {
int pirValue = digitalRead(pirSensorPin);
if (pirValue == HIGH) {
digitalWrite(ledPin, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Motion detected!");
Serial.println("Motion detected!");
} else {
digitalWrite(ledPin, LOW);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" No motion ");
lcd.setCursor(0, 1);
lcd.print(" detected! ");
}
delay(1000);
}
what if I dont have a motion sensor, or at least one that looks like that
can anything else work
@@pechitashouse4778 yes connecting pin2 to 5v should trigger the alarm.