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

КОМЕНТАРІ • 65

  • @vrushalikatta9226
    @vrushalikatta9226 6 років тому +3

    sir,
    i want bidirectional relay using 2 ultrasonic sensors and lcd, can you give me the programming related to this.

  • @sandilemthabela9913
    @sandilemthabela9913 Рік тому +1

    lcd.begin(); isn't working it says there is an error

  • @15-md.shadmanshakib28
    @15-md.shadmanshakib28 9 місяців тому

    brother...program telling you have used 20*4 lcd..did you??

  • @navin7088
    @navin7088 Рік тому

    It is showing no matching function for call to 'LiquidCrystal_I2C::begin()'

  • @Jyotika_Nilgar_0707
    @Jyotika_Nilgar_0707 3 роки тому

    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

  • @electronicsideas1361
    @electronicsideas1361 Рік тому

    It's good Idea but can we make rpm counter and objet counter in one lcd?

  • @petersundayudoh9965
    @petersundayudoh9965 10 місяців тому

    Please what type of power supply was use for this project?

  • @bonsanchez3231
    @bonsanchez3231 2 роки тому

    How use buzzer when 10.people inside was the buzzer active

  • @kpinnovations6613
    @kpinnovations6613 3 роки тому

    How can I add a relay when people counter is one relay is one when people is 0 relay will be off

  • @technoshrinivas
    @technoshrinivas Рік тому

    Sir from where I want to give supply for working this project

  • @3m_art001
    @3m_art001 4 роки тому

    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

    • @RoboticaDIY
      @RoboticaDIY  4 роки тому

      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

  • @abhisekmohanty5978
    @abhisekmohanty5978 10 місяців тому

    Sir how can I contact your account this project. Coz I'm trying but i can't complit it.

  • @ab...1
    @ab...1 3 роки тому

    How to set counting limit inside the display I.e. edit display...

  • @erfandaniel6586
    @erfandaniel6586 5 років тому

    How can i change the statement in lcd, means the words with single sensor

  • @sreeragaraj2580
    @sreeragaraj2580 4 роки тому

    How about the delay provided???

  • @shamshareshaik4159
    @shamshareshaik4159 5 років тому

    can the Range of the Sensor is increasable

  • @gaminginspace7731
    @gaminginspace7731 5 років тому

    Can u have joystick connected to it and how

  • @vaibhav3458
    @vaibhav3458 5 років тому

    My lcd screen is showing a bright light after adding the program
    What should i do???

    • @RoboticaDIY
      @RoboticaDIY  5 років тому +1

      adjust potentiometer.. it will work.

  • @Hariomyadav-sb5fl
    @Hariomyadav-sb5fl 5 років тому

    How can I use the same code using serial monitor plzzz help

  • @GAMER-wc6lb
    @GAMER-wc6lb 4 роки тому

    How to on lights when person enters and off when there is no person in room

  • @purabjindal7296
    @purabjindal7296 4 роки тому

    how to make it without i2c module

  • @muhammadadeel891
    @muhammadadeel891 5 років тому

    sir what library do you used for i2c

  • @lammabij1864
    @lammabij1864 3 роки тому

    Can i use IR sensor instead

  • @AyushSaxena-zw8pb
    @AyushSaxena-zw8pb Рік тому

    To reduce the wiring

  • @bossmac5484
    @bossmac5484 5 років тому

    my lcd screen is just blank i need help. the lcd is on but black blocks no numbers or letters.

  • @hamsaranirajarathinam8055
    @hamsaranirajarathinam8055 4 роки тому

    Can I get report for this project from you?

  • @shubhamchachan6440
    @shubhamchachan6440 4 роки тому

    My circuit is not working please help me out of these please give me ur mail so that I can send u all details

  • @sneraas
    @sneraas 2 роки тому

    This is not bi-directional, it's still only sensing movement in the Z-axis, uuuuuuuunhelpfull

  • @user-pg4rd9tv5u
    @user-pg4rd9tv5u 8 місяців тому

    Which language?

  • @AmazingMJ07
    @AmazingMJ07 4 роки тому

    if its single door its don't work :(

  • @nonfungibletrauma
    @nonfungibletrauma 4 роки тому

    What if theres someone inside already?

  • @sportsbossph
    @sportsbossph 6 років тому

    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

    • @RoboticaDIY
      @RoboticaDIY  6 років тому +2

      Grumpy Creative If you are using I2C, adjust lcd contrast by adjusting potentiometer on I2C.

    • @sportsbossph
      @sportsbossph 6 років тому +1

      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...

    • @RoboticaDIY
      @RoboticaDIY  6 років тому +2

      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
      }

    • @abdullaalmasum4945
      @abdullaalmasum4945 6 років тому

      Thank you very much, but can we add an alarm like When the room is full,,the alarm will turn on...

    • @shubhamchachan6440
      @shubhamchachan6440 4 роки тому

      But in video u have not added potentiometer

  • @shubhamchachan6440
    @shubhamchachan6440 4 роки тому

    In this no requirement for potentiometer

    • @RoboticaDIY
      @RoboticaDIY  4 роки тому

      we are using I2C, so no need of potentiometer, I2C has its own potentiometer on board, you can it is in blue color.

  • @neetapatel9032
    @neetapatel9032 4 роки тому

    Bro how to increase length of and sensor it is 9cm I need more then 20 cm tell me fast

    • @RoboticaDIY
      @RoboticaDIY  4 роки тому +1

      You have to change two things
      first change in Line number 40
      if (distance 20 && distance

  • @reginejoyaguilera6343
    @reginejoyaguilera6343 6 років тому

    It count countinously even no motion detected

    • @RoboticaDIY
      @RoboticaDIY  6 років тому

      make sure you place sensor atleast 20cm apart from all object. means front area should be clear.

    • @azizaja8255
      @azizaja8255 5 років тому

      @@RoboticaDIY if it more than 20cm that sensor not working?

  • @shubhamchachan6440
    @shubhamchachan6440 4 роки тому

    how to add 12C library

    • @RoboticaDIY
      @RoboticaDIY  4 роки тому +1

      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!!!

  • @angelap5897
    @angelap5897 4 роки тому

    0:57

  • @chandragirikondababu5079
    @chandragirikondababu5079 6 років тому

    Sir how to get download code and how it write.

    • @RoboticaDIY
      @RoboticaDIY  6 років тому

      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.

  • @pierricdoublet6248
    @pierricdoublet6248 5 років тому

    Marche pas !!!LCD reste blanc !

  • @psp759
    @psp759 4 роки тому

    Give me the code

    • @RoboticaDIY
      @RoboticaDIY  4 роки тому

      Please check description

    • @psp759
      @psp759 4 роки тому

      Robotica DIY I want to establish when we move the object in and out in a straight line