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

ความคิดเห็น • 44

  • @vinayaksrasal437
    @vinayaksrasal437 4 ปีที่แล้ว

    Delay 3000 & Non repeatable trigger
    Working fine 💯

  • @3m_art001
    @3m_art001 5 ปีที่แล้ว

    The pir sensor is in repeatable trigger mode or non repeatable trigger mode????

  • @mohamedshatla
    @mohamedshatla 6 ปีที่แล้ว

    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

  • @christ520
    @christ520 5 ปีที่แล้ว

    My led blinks with motion, my display is lit but it's blank with no counting. Same components. Any ideas?

  • @norbreck3017
    @norbreck3017 3 ปีที่แล้ว

    what if someone leaves the room? how to reduce the count?

  • @gagan016
    @gagan016 6 ปีที่แล้ว

    Bro edit coding section and increase the time delay upto 1800. i guranted it will work correctely

  • @praveenmedhe5879
    @praveenmedhe5879 4 ปีที่แล้ว

    Sir i have get this problem that(Error while setting serial port parameters:9,600 N 8 1

  • @yuddiwijaya6786
    @yuddiwijaya6786 5 ปีที่แล้ว

    Why void loop val = digitalread is not declared?

  • @chandinilalge9651
    @chandinilalge9651 2 ปีที่แล้ว

    Can u share us the steps to connect the circuit diagram

  • @vaibhav.tanwar
    @vaibhav.tanwar 6 ปีที่แล้ว

    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.

  • @praveenmedhe5879
    @praveenmedhe5879 4 ปีที่แล้ว

    Sir I want to edit this but I dont know the prosses so plz help me plz give step by step

  • @jorelletuyor
    @jorelletuyor 3 ปีที่แล้ว

    The circuit diagram is wrong. Even if you thoroughly follow it, it will always show wrong result.

  • @dennismartey6325
    @dennismartey6325 5 ปีที่แล้ว

    sir i am having this error when compiling" a function-definition is not allowed here before '{' token"please help

  • @nasrinnorlizam5606
    @nasrinnorlizam5606 3 ปีที่แล้ว

    Sir i cannot upload the coding to circuit.Can you help me please!!

  • @praveenmedhe5879
    @praveenmedhe5879 4 ปีที่แล้ว

    I have done all as per your crucite but outup is not showing on lcd

    • @RoboticaDIY
      @RoboticaDIY  4 ปีที่แล้ว

      check you PIR sensor, some time it doest work because of time trigger and sensitivity. you can adjust it through yellow port.

  • @Jaspay
    @Jaspay 6 ปีที่แล้ว

    i have a smaller breadboard so does it matter where i put the wires in the holes of the breadboard?

    • @RoboticaDIY
      @RoboticaDIY  6 ปีที่แล้ว

      no matter it is smaller. but connect according to circuit diagram.

  • @QuebecoisSti
    @QuebecoisSti 5 ปีที่แล้ว

    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?

    • @renrealmaesobrepena9409
      @renrealmaesobrepena9409 ปีที่แล้ว

      Hi, have u fixed this problem?

    • @QuebecoisSti
      @QuebecoisSti ปีที่แล้ว

      @@renrealmaesobrepena9409 it's been a while (4years) i don't even remember ! Haha

  • @rogersoduor4200
    @rogersoduor4200 5 ปีที่แล้ว

    can i have the circuit diagram for the connection

  • @johnedmarmoncada7828
    @johnedmarmoncada7828 6 ปีที่แล้ว

    Bro I have a problem I follow all of your instruction but if i start the arduino it automatically counting please help me

    • @romanbriley2740
      @romanbriley2740 4 ปีที่แล้ว +1

      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.

  • @NumanSrn
    @NumanSrn 5 ปีที่แล้ว +1

    My friend I use your system but it didn’t work. Please help me.

    • @RoboticaDIY
      @RoboticaDIY  5 ปีที่แล้ว

      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.

    • @NumanSrn
      @NumanSrn 5 ปีที่แล้ว

      I will try that

    • @NumanSrn
      @NumanSrn 5 ปีที่แล้ว

      Robotica DIY
      hi bro again. I used that diagram but not working. Please help me. Can you send email your system diagram photos?

    • @RoboticaDIY
      @RoboticaDIY  5 ปีที่แล้ว

      @@NumanSrn see description. code and diagram are available on website.

  • @rogersoduor4200
    @rogersoduor4200 5 ปีที่แล้ว +2

    my program is counting without stop
    please help

    • @marajsiddiki3199
      @marajsiddiki3199 5 ปีที่แล้ว

      did u fix your code..I have same problem

    • @romanbriley2740
      @romanbriley2740 4 ปีที่แล้ว

      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.

    • @uzairsheikh4673
      @uzairsheikh4673 8 หลายเดือนก่อน

      was you solve this problem?

    • @uzairsheikh4673
      @uzairsheikh4673 8 หลายเดือนก่อน

      ​@@marajsiddiki3199can you help me

    • @uzairsheikh4673
      @uzairsheikh4673 8 หลายเดือนก่อน

      ​@@romanbriley2740
      can you define this in easy wording

  • @sudhagarsundar
    @sudhagarsundar 4 ปีที่แล้ว

    How to reset the count value

    • @RoboticaDIY
      @RoboticaDIY  4 ปีที่แล้ว

      press reset button on arduino.

  • @uzairsheikh4673
    @uzairsheikh4673 8 หลายเดือนก่อน

    Bro I have a problem I follow all of your instruction but if i start the arduino it automatically counting please help me
    @RoboticaDIY

  • @praveenmedhe5879
    @praveenmedhe5879 4 ปีที่แล้ว

    How to edit this

  • @creativebuddies9997
    @creativebuddies9997 5 ปีที่แล้ว

    lol you great