Bi-Directional Visitor Counter using single ultrasonic sensor with LCD
Вставка
- Опубліковано 6 вер 2024
- Bi-Directional Visitor Counter using single ultrasonic 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/2zg8aeX (I2C)
amzn.to/2vmUlLw (Ultrasonic sensor)
amzn.to/2wxPmWz (Breadboard)
amzn.to/2vJ3lvo (Jumper wire)
#include (Wire.h) //instead of parenthesis () put angle bracket as UA-cam description does not allow angle bracket
#include (LiquidCrystal_I2C.h)
#define trigPin 13
#define echoPin 12
// Find LCD address for I2C in this tutorial it is 0x3f
LiquidCrystal_I2C lcd(0x3f, 16, 2);
int counter = 0;
int currentState1 = 0;
int previousState1 = 0;
int currentState2 = 0;
int previousState2 = 0;
int inside = 0;
int outside = 0;
void setup()
{
// initialize the LCD
lcd.begin();
//Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop()
{
lcd.setCursor(0, 0);
lcd.print("IN: ");
lcd.setCursor(8, 0);
lcd.print("OUT: ");
lcd.setCursor(0, 1);
lcd.print("Total Inside: ");
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance (= 9){
currentState1 = 1;
}
else {
currentState1 = 0;
}
delay(100);
if(currentState1 != previousState1){
if(currentState1 == 1){
counter = counter + 1;}
lcd.setCursor(14, 1);
lcd.print(counter);
inside = inside +1;}
lcd.setCursor(4, 0);
lcd.print(inside);
if (distance ) 9 && distance (= 18){
currentState2 = 1;
}
else {
currentState2 = 0;
}
delay(100);
if(currentState2 != previousState2){
if(currentState2 == 1){
counter = counter - 1;}
lcd.setCursor(14, 1);
lcd.print(counter);
outside = outside +1;}
lcd.setCursor(13, 0);
lcd.print(outside);
lcd.setCursor(14, 1);
lcd.print(counter);
if (counter ) 9 || counter ( 0){
lcd.setCursor(14, 1);
lcd.print(counter);
delay(100);
lcd.clear();
}
}
sir,
i want bidirectional relay using 2 ultrasonic sensors and lcd, can you give me the programming related to this.
lcd.begin(); isn't working it says there is an error
brother...program telling you have used 20*4 lcd..did you??
It is showing no matching function for call to 'LiquidCrystal_I2C::begin()'
2nd row of lcd is not displaying anything and in 1st row only the black boxes are displayed not the letters
plz tell me the solution
It's good Idea but can we make rpm counter and objet counter in one lcd?
Please what type of power supply was use for this project?
How use buzzer when 10.people inside was the buzzer active
How can I add a relay when people counter is one relay is one when people is 0 relay will be off
Sir from where I want to give supply for working this project
Can u tell me the code for relay
Like if one person enters then the light turns on and when there is no one in the room the light turns off??
Btw big fan
Ultrasonic sensor is not suitable for application you want, It can be easily done with PIR motion detection sensor, its range is 6 to 7 meter and it detects human and animal. I have made video you can watch ua-cam.com/video/lLk1T6JrRjQ/v-deo.html
Sir how can I contact your account this project. Coz I'm trying but i can't complit it.
How to set counting limit inside the display I.e. edit display...
How can i change the statement in lcd, means the words with single sensor
How about the delay provided???
can the Range of the Sensor is increasable
Can u have joystick connected to it and how
My lcd screen is showing a bright light after adding the program
What should i do???
adjust potentiometer.. it will work.
How can I use the same code using serial monitor plzzz help
How to on lights when person enters and off when there is no person in room
how to make it without i2c module
sir what library do you used for i2c
LCD_I2C
Can i use IR sensor instead
Yes you can use.. But you have to use 2
To reduce the wiring
my lcd screen is just blank i need help. the lcd is on but black blocks no numbers or letters.
Yes same
same do u have any sollution bout that?
@@felixprabowo321 adjust pot on i2c
Can I get report for this project from you?
My circuit is not working please help me out of these please give me ur mail so that I can send u all details
This is not bi-directional, it's still only sensing movement in the Z-axis, uuuuuuuunhelpfull
Which language?
if its single door its don't work :(
What if theres someone inside already?
kick them out!!!
Hi SIr i try to follow but my screen is just blue but no problem with my code, no text displaying do you what happen? thank you much
Grumpy Creative If you are using I2C, adjust lcd contrast by adjusting potentiometer on I2C.
thank you so much by the way i have one last question ...
how to put limit in counting entrance for example the maximum inside is 10 so i will limit to 10 then if it will go to 11 there will be an error that says room is full? newbie here.. thank you
Btw i'll subscribe you deserved more than it...
add this line after "counter = counter+1" line, for room is full
counter = counter + 1;}
if(counter > 10){
lcd.clear();
lcd.print("Room is Full"); // room is full
}
add this line for limiting visitor is not a negative number, just after
"counter = counter-1" line,
counter = counter - 1;}
if(counter < 0){
lcd.clear();
lcd.print("Room is Empty"); // room is empty
}
Thank you very much, but can we add an alarm like When the room is full,,the alarm will turn on...
But in video u have not added potentiometer
In this no requirement for potentiometer
we are using I2C, so no need of potentiometer, I2C has its own potentiometer on board, you can it is in blue color.
Bro how to increase length of and sensor it is 9cm I need more then 20 cm tell me fast
You have to change two things
first change in Line number 40
if (distance 20 && distance
It count countinously even no motion detected
make sure you place sensor atleast 20cm apart from all object. means front area should be clear.
@@RoboticaDIY if it more than 20cm that sensor not working?
how to add 12C library
Download library from link mention below in the description. Open Arduino IDE > Sketch > include library > ADD .zip Library > find where you downloaded libary in zip file. > click ok. DONE!!!
0:57
Sir how to get download code and how it write.
visit roboticadiy.com/bi-directional-visitor-counter-using-single-ultrasonic-sensor-with-lcd/
you can copy code and paste in Arduino IDE then upload code to arduino.
Marche pas !!!LCD reste blanc !
Give me the code
Please check description
Robotica DIY I want to establish when we move the object in and out in a straight line