How to make a Security System with Ultrasonic Sensor and Arduino

Поділитися
Вставка
  • Опубліковано 18 січ 2025

КОМЕНТАРІ • 65

  • @IBRAHIMABEDAL_NABI
    @IBRAHIMABEDAL_NABI 3 місяці тому +13

    project code
    //Security Alarm with Ultrasonic Sensor//
    #define trigPin 6
    #define echoPin 5
    #define buzzer 2
    float new_delay;
    void setup()
    {
    Serial.begin (9600);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    pinMode(buzzer,OUTPUT);

    }
    void loop()
    {
    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;
    new_delay= (distance *3) +30;
    Serial.print(distance);
    Serial.println(" cm");
    if (distance < 50)
    {
    digitalWrite(buzzer,HIGH);
    delay(new_delay);
    digitalWrite(buzzer,LOW);

    }
    else
    {
    digitalWrite(buzzer,LOW);
    }

    delay(200);
    }

  • @banttubanttu7408
    @banttubanttu7408 3 роки тому +8

    I want the same with high sensitivity, I mean It should work for any movement take place with a distance as much as 30-40 feet from the sensor. Thanks for your projects , you deserve more viewers.

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

      You can adjust the distance in the coding

    • @sadiyamashayeen6905
      @sadiyamashayeen6905 3 місяці тому

      @@boobaljanakiramulu7277in which part of the code can I adjust the distance. First example I want the distance of buzzer beeping from 3 feet to the closesest. So, what number should I put in the code & which part of the code

  • @_sourx4803
    @_sourx4803 2 роки тому +3

    HII TYSMM I DIDNT PAY ATTNETION IN CLASS HAHA AND I DID THIS LAST MINUTE AND GOT GOT MARKS THANKS AGAIN

  • @Szwaz9765
    @Szwaz9765 7 місяців тому +1

    It is working but my buzzer is making less sound how to fix it

  • @johnjeffersonebergado7496
    @johnjeffersonebergado7496 2 роки тому +2

    Works fine for me Thank you for uploading!!!

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

      Did you use 7v or 9v?
      Also, some of the comments said that the code is not working, how does it work with you? Please help me

  • @adam.boy23
    @adam.boy23 11 місяців тому +1

    yo what is after else function in line 38
    I can't find it in the video. Also there are many bugs in the code

  • @leni9605
    @leni9605 2 роки тому +10

    something is wrong with the code. The buzzer wont top beeping even when nothing is in front of the sensor. Check the code

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

      Same...did u do any changes...pls let me know if u hv

    • @dulakshirodrigo2947
      @dulakshirodrigo2947 4 місяці тому +1

      Dude the sensor is detecting another object nearby .so remove any objects nearby

    • @dulakshirodrigo2947
      @dulakshirodrigo2947 4 місяці тому +1

      Just kidding it did not work for me as well

  • @kalpana8395
    @kalpana8395 6 днів тому

    Can you add screen on it

  • @emmaliaRazis
    @emmaliaRazis 6 місяців тому +7

    //Tech Trends Razis
    //Object Detection Alarm
    // Define pins numbers
    const int trigPin = 13; //Connect Trig pin in Ultrasonic Sensor to Arduino Pin 13
    const int echoPin = 12; //Connect Echo pin in Ultrasonic Sensor to Arduino Pin 13
    const int buzzer = 11; //Connect Positive pin of Buzzer to Arduino Pin 11
    const int ledPin = 10; //Connect Positive pin of LED to Arduino Pin 10
    // Define variables
    long duration;
    int distance;
    int safetyDistance;
    void setup() {
    pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
    pinMode(echoPin, INPUT); // Sets the echoPin as an Input
    pinMode(buzzer, OUTPUT);
    pinMode(ledPin, OUTPUT);
    Serial.begin(9600); // Starts the serial communication
    }
    void loop() {
    // Clears the trigPin
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    // Sets the trigPin on HIGH state for 15 micro seconds
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(15);
    digitalWrite(trigPin, LOW);
    // Reads the echoPin, returns the sound wave travel time in microseconds
    duration = pulseIn(echoPin, HIGH);
    // Calculate the distance
    distance= duration*0.034/2;
    safetyDistance = distance;
    if (safetyDistance

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

    Did you use 7v or 9v battery?

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

      Please answer me I have a project and the deadline after 5 days

  • @agdimi5720
    @agdimi5720 8 місяців тому +1

    Did anyone do it with scratch 4 arduino? Because I would like some help with the code s4a. It's for elementary school class

  • @queen_girl56
    @queen_girl56 10 місяців тому +1

    Thnk u thnk u so much it's working

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

    i do not have a buzzer...is it still possible to make this?

    • @Megafish1024
      @Megafish1024 3 місяці тому

      you can LED lights instead

  • @yalamanchilisameera7030
    @yalamanchilisameera7030 2 роки тому +1

    mam your project is too good i tried this but i can't able to select the port in the tools can you please help me... i have to submit this project tomorrow plzzz help me mam....

  • @DailyCarnagecodm
    @DailyCarnagecodm 2 місяці тому

    tells me that there is a stray # in it but doesnt work pls help

  • @Chathu-po7vd
    @Chathu-po7vd Рік тому +1

    How to make in this program

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

    Thankyou so much!! Worked well for me❤

  • @TakahiroShinjo-v2b
    @TakahiroShinjo-v2b 3 місяці тому

    it says these errors :Compilation error: a function-definition is not allowed here before '{' token
    anyone pls help me fix it

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

    thank you but my buzzer is super quiet what could i do to fix this?

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

      Amplify it, use a transistor circuit

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

    Is there barcoding for the device too?

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

    While I upload the coding itself the buzzer starts to sound I done all thinks as per the circuit diagram why it's happening

    • @asg2832
      @asg2832 2 роки тому +2

      when finally uploading the coding to the board add the buzzer then it's alright

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

    Library file choosen is needed or not

  • @matheussesi-u6t
    @matheussesi-u6t 3 місяці тому

    PARABENS POR DEIXAR O CODIGO NOS COMENTAROS, BEIJOS

  • @Mayank_m201
    @Mayank_m201 8 місяців тому

    thank you...🤓👍

  • @industrialelectricalbd6900
    @industrialelectricalbd6900 5 місяців тому

    GOOD JOB MAM.

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

    what volt of buzzer are used in this project?

    • @Arafat325
      @Arafat325 7 місяців тому

      I don't know 😅

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

    does this projeft use battery 9v?

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

    Can I replace the beeper with 5V pump?

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

      Yes

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

      ​@@n_tech3861 could you tell where to connect battery to audrino uno

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

      ​@@mdtameem324just connect the wire of the battery to :
      Black wire gnd
      Red wire to vin

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

    How many voltage inpute

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

    The voice is quite what should I do

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

    Yesss

  • @هندسة-ذ4خ
    @هندسة-ذ4خ 2 роки тому

    Hi, i have a project on Arduino , can u help me plz?

  • @hanastudio-n2e
    @hanastudio-n2e Рік тому +1

    can you upload the link coding ?

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

    hyyy i am getting an error

  • @shuttyskenzin9237
    @shuttyskenzin9237 3 роки тому +1

    Hi please check your code, your code has some error. please go in ur code and verify it please thx and reply fast thx

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

      Hey can you please mention where exactly is it going wrong because I am unable to find it

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

      @@n_tech3861 Hi, so when i run the code it said something like "can have definition variable before '{' token" something like that

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

      @@shuttyskenzin9237 you may have missed an opening or a closing bracket

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

      Please who has the correct code

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

    Mam please please please 🙏 send the code in my comments

    • @n_tech3861
      @n_tech3861  3 роки тому +1

      #define trigPin 6
      #define echoPin 5
      #define buzzer 2
      float new_delay;
      void setup()
      {
      Serial.begin (9600);
      pinMode(trigPin, OUTPUT);
      pinMode(echoPin, INPUT);
      pinMode(buzzer,OUTPUT);

      }
      void loop()
      {
      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;
      new_delay= (distance *3) +30;
      Serial.print(distance);
      Serial.println(" cm");
      if (distance < 50)
      {
      digitalWrite(buzzer,HIGH);
      delay(new_delay);
      digitalWrite(buzzer,LOW);

      }
      else
      {
      digitalWrite(buzzer,LOW);
      }

      delay(200);
      }

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

      Jjj

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

    Saan po yung code

  • @rsddd04
    @rsddd04 4 місяці тому

    😂😂