Arduino Tutorial #21 how to make counter using PIR sensor with LCD
ฝัง
- เผยแพร่เมื่อ 20 ก.ย. 2024
- Arduino Tutorial #21 how to make counter using PIR (motion detection sensor) with LCD
Scroll down for code.....
Please like & Subscribe for more videos
If you want to support my video please buy any product through my amazon affiliate link. I will receive a commission, at no extra cost to you.
LIST OF COMPONENT (affiliate links)
amzn.to/2fvSRJq (Arduino)
amzn.to/2yBk7eT (LCD display)
amzn.to/2vqnDHc (PIR sensor)
amzn.to/2vmSK8l (Resistor)
amzn.to/2vSpUON (LED)
amzn.to/2wxPmWz (Breadboard)
amzn.to/2vJ3lvo (Jumper wire)
#include (LiquidCrystal.h) // instead of parenthesis () put angle bracket as TH-cam description does not allow angle bracket
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int ledPin = 13;
int pirPin = 10;
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
int counter = 0;
int currentState = 0;
int previousState = 0;
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(pirPin, INPUT); // declare sensor as input
lcd.begin(16, 2);
lcd.setCursor(4, 0);
lcd.print("counter");
}
void loop(){
val = digitalRead(pirPin); // read PIR sensor input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
currentState = 1;
// We only want to print on the output change, not state
pirState = HIGH;
delay(1000);
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
currentState = 0;
// We only want to print on the output change, not state
pirState = LOW;
}
}
if(currentState != previousState){
if(currentState == 1){
counter = counter + 1;
lcd.setCursor(4,1);
lcd.print(counter);
delay(200);
}
}
}
Delay 3000 & Non repeatable trigger
Working fine 💯
The pir sensor is in repeatable trigger mode or non repeatable trigger mode????
if i want make this but during the object in front of the sensor no counting until we leave the sensor and other object cutting the sensor
My led blinks with motion, my display is lit but it's blank with no counting. Same components. Any ideas?
what if someone leaves the room? how to reduce the count?
Bro edit coding section and increase the time delay upto 1800. i guranted it will work correctely
Sir i have get this problem that(Error while setting serial port parameters:9,600 N 8 1
Why void loop val = digitalread is not declared?
Can u share us the steps to connect the circuit diagram
Sir I want to make a machine which counts OK piece trough sensor and count reject piece by one push button and same data should display in the 4 digit 7 segment display and also want to get the real time data to computer in excel.. Please help.
Sir I want to edit this but I dont know the prosses so plz help me plz give step by step
The circuit diagram is wrong. Even if you thoroughly follow it, it will always show wrong result.
sir i am having this error when compiling" a function-definition is not allowed here before '{' token"please help
Sir i cannot upload the coding to circuit.Can you help me please!!
I have done all as per your crucite but outup is not showing on lcd
check you PIR sensor, some time it doest work because of time trigger and sensitivity. you can adjust it through yellow port.
i have a smaller breadboard so does it matter where i put the wires in the holes of the breadboard?
no matter it is smaller. but connect according to circuit diagram.
my counter is always incrementing and led turn off when motion. counter stops and led stays on when seeing no motion. I am trying adjusting the 2 pot for sensitivity & time delay but doesn't seem to work... what I should take a look at?
Hi, have u fixed this problem?
@@renrealmaesobrepena9409 it's been a while (4years) i don't even remember ! Haha
can i have the circuit diagram for the connection
Bro I have a problem I follow all of your instruction but if i start the arduino it automatically counting please help me
I had the same problem but fixed it, First thing I did was set the right potentiometer on the PIR all the way to the left. Secondly move the jumper pin to Non-repeatable on the PIR sensor and that fixed it for me, I hope this helps you out.
My friend I use your system but it didn’t work. Please help me.
what is not working? check you have connected all the things properly first. if PIR sensor not detecting ? then adjust PIR sensor senstivity and time trigger (On PIR sensor there is trimport where you can adjust it). I hope this will help.
I will try that
Robotica DIY
hi bro again. I used that diagram but not working. Please help me. Can you send email your system diagram photos?
@@NumanSrn see description. code and diagram are available on website.
my program is counting without stop
please help
did u fix your code..I have same problem
I had the same problem but fixed it, First thing I did was set the right potentiometer on the PIR all the way to the left. Secondly move the jumper pin to Non-repeatable on the PIR sensor and that fixed it for me, I hope this helps you out.
was you solve this problem?
@@marajsiddiki3199can you help me
@@romanbriley2740
can you define this in easy wording
How to reset the count value
press reset button on arduino.
Bro I have a problem I follow all of your instruction but if i start the arduino it automatically counting please help me
@RoboticaDIY
How to edit this
lol you great