Arduino Ultrasonic Motion Sensor: Motion Sensor and LED project

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 พ.ย. 2022
  • I wanted to make a continuation to the first video, implementing the addition of a motion sensor. We combined LED lights with a motion sensor to make a cool distance detector. Make sure you like and subscribe so that you don't miss the next video where we might implement the buzzer or remote.

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

  • @Waiduino
    @Waiduino  ปีที่แล้ว +16

    const int echo=13;
    const int trig=12;
    int LED1=2;
    int LED2=3;
    int LED3=4;
    int LED4=5;
    int duration=0;
    int distance=0;
    void setup() {
    pinMode(trig,OUTPUT);
    pinMode(echo,INPUT);
    pinMode(LED1,OUTPUT);
    pinMode(LED2,OUTPUT);
    pinMode(LED3,OUTPUT);
    pinMode(LED4,OUTPUT);
    Serial.begin(9600);
    }
    void loop() {
    digitalWrite(trig,HIGH);
    delay(1000);
    digitalWrite(trig,LOW);
    digitalWrite(LED1,LOW);
    digitalWrite(LED2,LOW);
    digitalWrite(LED3,LOW);
    digitalWrite(LED4,LOW);
    duration=pulseIn(echo,HIGH);
    distance= (duration/2)/28.5;
    if (distance=10 && distance 20&& distance

    • @ericknova2989
      @ericknova2989 7 หลายเดือนก่อน +1

      Buen día, se puede agregar un buzzer
      ¿'

    • @Waiduino
      @Waiduino  7 หลายเดือนก่อน +2

      @@ericknova2989 Hola, no hablo muy bien español. Sí, puedes agregar un buzzer. Puedo hacer un vídeo sobre eso si estás interesado.

    • @ericknova2989
      @ericknova2989 7 หลายเดือนก่อน +2

      @@Waiduino Hola, si, seria interesante agregar un buzzer que se active con el código que creaste.

    • @Waiduino
      @Waiduino  7 หลายเดือนก่อน +2

      @@ericknova2989 Haré mi próximo video sobre cómo agregar un buzzer para este proyecto. Gracias por tu comentario.

    • @Waiduino
      @Waiduino  6 หลายเดือนก่อน +3

      @@ericknova2989 Se acaba de publicar un nuevo vídeo sobre el sensor y el buzzer. ¡Disfrutar! Gracias por tu comentario

  • @manjuyadav-ws4xd
    @manjuyadav-ws4xd 4 หลายเดือนก่อน +2

    Yo the channel owner is legend for replying to all comments most TH-camrs dont do that

    • @Waiduino
      @Waiduino  4 หลายเดือนก่อน +1

      Haha thanks so much! I try to reply to every comment since I’m thankful you guys watch my videos and because I mainly wanted to help other people create and learn about circuits. I always try to reply to comments so thanks for noticing!!

  • @layanshali8015
    @layanshali8015 3 หลายเดือนก่อน +1

    Hello just wanted to say thanks, I tried this in my class, it was my first time using ultrasonic and it worked💗

    • @Waiduino
      @Waiduino  3 หลายเดือนก่อน +1

      Yea of course! Thanks so much for your kind words.

  • @Bianchi77
    @Bianchi77 หลายเดือนก่อน +1

    Creative video, thank you :)

    • @Waiduino
      @Waiduino  หลายเดือนก่อน +1

      Thank you!! Did you build the project?

  • @lyndalekirk6883
    @lyndalekirk6883 หลายเดือนก่อน +1

    Very well explained thanks

    • @Waiduino
      @Waiduino  19 วันที่ผ่านมา

      Thank you so much! Were you able to make the circuit?

  • @DannyYuson
    @DannyYuson หลายเดือนก่อน +1

    endless thanks

    • @Waiduino
      @Waiduino  หลายเดือนก่อน +1

      No problem! Glad you enjoyed and learned something. Did you have to make it for a school project?

  • @arinaitwejoe19992
    @arinaitwejoe19992 5 หลายเดือนก่อน +1

    Hello thanks very much , so i have an inquire how can i use an infrared sensor as a level sensor and also with like 2 indicator LED lights ???

    • @Waiduino
      @Waiduino  5 หลายเดือนก่อน +2

      Thank you so much for your comment! It is possible to use the infrared sensor as a level sensor however it would require much more instructions than I can show here. Would you like me to create a video to show how to create this project?

  • @Sabbir-ln3bx
    @Sabbir-ln3bx 19 วันที่ผ่านมา +1

    What was the resistance of the resistor you used? And how did you wire the leds, and the wires next to the led?

    • @Sabbir-ln3bx
      @Sabbir-ln3bx 19 วันที่ผ่านมา +1

      oh wait nvm i think i got it.

    • @Waiduino
      @Waiduino  19 วันที่ผ่านมา +1

      Sounds good thanks for commenting! Were you able to create the circuit?

    • @Sabbir-ln3bx
      @Sabbir-ln3bx 19 วันที่ผ่านมา

      @@Waiduino it works thanks.

  • @GladiatorX-te6bx
    @GladiatorX-te6bx 15 วันที่ผ่านมา +1

    Yo. Can you tell me how to switch off two motors if the distance is less than 20 for example, and otherwise keep it on? Thanks

    • @Waiduino
      @Waiduino  12 วันที่ผ่านมา

      Sure which motors are you interested in? Like servo?

  • @missma.eugeniamartinezgonz560
    @missma.eugeniamartinezgonz560 8 วันที่ผ่านมา +1

    Como puede tu código mandar la información a un celular, supongamos un lugar separado, como cuando separas tu lugar, prende el foco rojo y manda la información a una pantalla.

    • @Waiduino
      @Waiduino  6 วันที่ผ่านมา +1

      Hola! Gracias por tu comentario. ¿Quieres conectar el arduino a un teléfono?

  • @mert5479
    @mert5479 วันที่ผ่านมา +1

    only one light blink you know why i pretty sure i put it together right

    • @Waiduino
      @Waiduino  17 ชั่วโมงที่ผ่านมา +1

      You copied the code exactly, right? What pins is each individual LED connected to. Make sure they are securely in.

  • @Mg28mg
    @Mg28mg 6 วันที่ผ่านมา +1

    Can we do this with uno and hc-sr04???

    • @Waiduino
      @Waiduino  6 วันที่ผ่านมา +1

      Yep! If I am not mistaken, I used the hc-sr04 in my video as well as the uno. Thanks for your comment!

  • @user-to6hm2wy8z
    @user-to6hm2wy8z 14 วันที่ผ่านมา +1

    What is the resister number you used bro?

    • @Waiduino
      @Waiduino  12 วันที่ผ่านมา +1

      I believed I used like 500 or 1k but feel free to use whatever you want. Lower resistance means brighter color so I normally like LEDS to shine more

  • @ili-sha
    @ili-sha 3 หลายเดือนก่อน +1

    how many ohms resistor did you use

    • @Waiduino
      @Waiduino  3 หลายเดือนก่อน +2

      Hi! It should be 330 ohms, I’m not entirely sure. The lower resistance, the brighter your LED is gonna be. Hope this helps!

  • @Sabbir-ln3bx
    @Sabbir-ln3bx 19 วันที่ผ่านมา +1

    How do you do it with all the leds on and when you put your hands closer to the leds they turn off one by one?

    • @Waiduino
      @Waiduino  19 วันที่ผ่านมา +1

      Hi so basically you would need to modify the code. I will do that for you right now if you would like. You just have to set the status to each LEF as on and then every second it detects a hand, it will turn off an LED by turning it off. Let me comment the code now

    • @Sabbir-ln3bx
      @Sabbir-ln3bx 19 วันที่ผ่านมา +1

      @@Waiduino ok

    • @Waiduino
      @Waiduino  19 วันที่ผ่านมา +1

      const int echo=13;
      const int trig=12;
      int LED1=2;
      int LED2=3;
      int LED3=4;
      int LED4=5;
      int duration=0;
      int distance=0;
      void setup() {
      pinMode(trig,OUTPUT);
      pinMode(echo,INPUT);
      pinMode(LED1,OUTPUT);
      pinMode(LED2,OUTPUT);
      pinMode(LED3,OUTPUT);
      pinMode(LED4,OUTPUT);
      Serial.begin(9600);
      }
      void loop() {
      digitalWrite(trig,HIGH);
      delay(1000);
      digitalWrite(trig,LOW);
      digitalWrite(LED1,HIGH);
      digitalWrite(LED2,HIGH);
      digitalWrite(LED3,HIGH);
      digitalWrite(LED4,HIGH);
      duration=pulseIn(echo,HIGH);
      distance= (duration/2)/28.5;
      if (distance=10 && distance 20&& distance

    • @Waiduino
      @Waiduino  19 วันที่ผ่านมา +1

      Does that work? Let me know

    • @Sabbir-ln3bx
      @Sabbir-ln3bx 19 วันที่ผ่านมา +1

      @@Waiduino it doesn't

  • @mvsaikartheek633
    @mvsaikartheek633 5 หลายเดือนก่อน +1

    hello how to give connections for led positive and negative and resistor?

    • @Waiduino
      @Waiduino  5 หลายเดือนก่อน

      You can find that all in the circuit diagram. The GND should connect to the railing which is connected to a resistor which connects to the negative side of the LED and the positive side connects to a pin on the Arduino designated in your code. You can find a walkthrough in my first ever video. Hope this helped!

    • @mvsaikartheek633
      @mvsaikartheek633 5 หลายเดือนก่อน +1

      @@Waiduino oh thank you

    • @Waiduino
      @Waiduino  5 หลายเดือนก่อน +1

      @@mvsaikartheek633 Sure no problem! Let me know if you have any other questions.

    • @mvsaikartheek633
      @mvsaikartheek633 5 หลายเดือนก่อน

      @@Waiduino okay 👍

  • @DanielMTB663
    @DanielMTB663 4 หลายเดือนก่อน +1

    Yo I am new to arduino so could you tell me what app you use to put the code into the thing

    • @Waiduino
      @Waiduino  4 หลายเดือนก่อน +2

      Yea for sure. I talked about this in my very first video but the compiler or IDE is something you have to download. Here is the link: www.arduino.cc/en/software Let me know if you have any other questions!!

    • @DanielMTB663
      @DanielMTB663 4 หลายเดือนก่อน +1

      @@Waiduino Thank you 😊

    • @Waiduino
      @Waiduino  4 หลายเดือนก่อน +1

      @@DanielMTB663 Yea of course! If you’re interested in other projects I would greatly appreciate it if you could check out some of my other videos since i’m really trying to grow my channel. Have you built any other projects?

    • @DanielMTB663
      @DanielMTB663 4 หลายเดือนก่อน +1

      @@Waiduino no this is my first project as I am trying to make an RC plane. I have subscribed to see more projects. (I am using the radar to ad to the plane)

    • @Waiduino
      @Waiduino  4 หลายเดือนก่อน +2

      @@DanielMTB663 Ohhhh that seems super interesting! Glad to see your working with the Arduino. Thank you for your support and if there’s any project ideas or assistance you need with the Arduino feel free to ask any questions!

  • @zeeshamt1695
    @zeeshamt1695 3 วันที่ผ่านมา +1

    Can u tell me the number of the risistor and the wites

    • @Waiduino
      @Waiduino  2 วันที่ผ่านมา +1

      I used a 1k ohm resistor. The higher resistance, the less bright your LED will be. What is your question about the wires?

  • @AKarts-ef4hq
    @AKarts-ef4hq 5 หลายเดือนก่อน +1

    const int echo=13;
    const int trig=12;
    int LED1=2;
    int LED2=3;
    int duration=0;
    int distance=0;
    void setup() {
    pinMode(trig,OUTPUT);
    pinMode(echo,INPUT);
    pinMode(LED1,OUTPUT);
    pinMode(LED2,OUTPUT);

    Serial.begin(9600);
    }
    void loop() {
    digitalWrite(trig,HIGH);
    delay(1000);
    digitalWrite(trig,LOW);
    digitalWrite(LED1,LOW);
    digitalWrite(LED2,LOW);
    duration=pulseIn(echo,HIGH);
    distance= (duration/2)/28.5;
    if (distance=10 && distance 20&& distance

  • @Curiousitypathofficial
    @Curiousitypathofficial 6 หลายเดือนก่อน +1

    the led is not lighting up how matter I try

    • @Waiduino
      @Waiduino  6 หลายเดือนก่อน +1

      Hmm i can assist you personally. Have you used a resistor and followed the diagram exactly? What pin did you attach it to on the Arduino?

  • @zainraza7126
    @zainraza7126 3 หลายเดือนก่อน +2

    hey their whenever i connect to 5V my arduino shuts off plz help ASAP thanks

    • @Waiduino
      @Waiduino  3 หลายเดือนก่อน +1

      Hi! I’ve had this issue in the past. Pay attention to where the 5v railing is and you might find the cause of the issue. Did you make sure all connections are correct?

    • @zainraza7126
      @zainraza7126 3 หลายเดือนก่อน +1

      @@Waiduino im not sure if my breadboard is properly or if the video is inverted u are saying to plug in the Sensor closest to the negative side right? Sorry i have a project on this and im stressed

    • @Waiduino
      @Waiduino  3 หลายเดือนก่อน +1

      @@zainraza7126 If you are referring to the sensor, the white wire is plugged to the rightmost pin on the sensor (the sensor circles should be pointed to the right). Is that what you are referring to?

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

    are you open to innovation project. ?

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

      Yea definitely! I have been working on a few but they take really long to finish them.

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

      Also don’t forget to check out my other videos with cool projects and different Arduino modules!

  • @projekter.original
    @projekter.original หลายเดือนก่อน +1

    Step1: Disconect Power from Arduino

    • @Waiduino
      @Waiduino  หลายเดือนก่อน +1

      Oh I forgot to add that to my video 😅😅. Did you make the project?

  • @user-ut6dr9pb7l
    @user-ut6dr9pb7l หลายเดือนก่อน +1

    It doesn't let me send an email here I don't know why

    • @Waiduino
      @Waiduino  หลายเดือนก่อน +2

      No give me your email address so I can send you an email

    • @user-ut6dr9pb7l
      @user-ut6dr9pb7l หลายเดือนก่อน +1

      @@Waiduino boqo lol boqo no space for email

    • @user-ut6dr9pb7l
      @user-ut6dr9pb7l หลายเดือนก่อน +1

      @@Waiduino I couldn't send the whole email since it didn't let me and no space and no numbers

    • @user-ut6dr9pb7l
      @user-ut6dr9pb7l หลายเดือนก่อน

      @@Waiduino Did you find it?

  • @naughtyboys2381
    @naughtyboys2381 2 หลายเดือนก่อน +2

    It's a distance sensor ig

    • @Waiduino
      @Waiduino  2 หลายเดือนก่อน +1

      Yea you could think about it like that. Did you get a a chance to make it?

    • @naughtyboys2381
      @naughtyboys2381 2 หลายเดือนก่อน +1

      @Waiduino yes long ago, btw . Motion sensing is different from distance sensing i think

    • @Waiduino
      @Waiduino  2 หลายเดือนก่อน +2

      @@naughtyboys2381 Thanks for pointing that out, your are correct. Thank you!

  • @fkj7761
    @fkj7761 6 หลายเดือนก่อน +1

    Hi

    • @Waiduino
      @Waiduino  6 หลายเดือนก่อน +1

      😂😂 Hi! Are you interested in Arduino

  • @user-ut6dr9pb7l
    @user-ut6dr9pb7l หลายเดือนก่อน +1

    Awesome video bruh can you help pls? thanks!

    • @Waiduino
      @Waiduino  หลายเดือนก่อน +2

      I’m glad you enjoyed the video! I can help, what seems to be the issue?

    • @user-ut6dr9pb7l
      @user-ut6dr9pb7l หลายเดือนก่อน +1

      @@Waiduino Heyy thank you! Do you have discord account?

    • @user-ut6dr9pb7l
      @user-ut6dr9pb7l หลายเดือนก่อน +1

      @@Waiduino Were not allowed to use arduino uno or any similar though so it's kinda a bit hard to choose but I think it's a small project since were not going to use arduino uno or any similar etc
      We have this type of list and I don't know which to choose for beginners raspberry pi
      Thanks!
      User Interface
      Basic
      Basic Kit (at least 2 from LEDs, Button Switches, Buzzer)
      Basic
      Bluetooth API (e.g. Blue Dot API)
      Basic
      Speech Recognition
      Basic
      Speech Output
      Basic
      e-mail Alerts
      Basic
      RFID input
      Basic
      Push Notifications to mobile using API like Instapush or Twilio
      Advanced
      Flask Server (or WebIoT) providing Web interface
      Advanced
      GUI created using TkInter or Pygame or guizero or similar
      Advanced
      Machine Learning
      Advanced
      GPIO connected Character Pad
      Advanced
      GPIO connected Joystick
      Advanced
      74HC595 & Bar Graph LED
      Advanced
      74HC595 & 4-digit 7-Segment Display
      Advanced
      74HC595 & LED Matrix 8x8 or bigger
      Advanced
      Output to an IoT broker such as Thingsboard
      Advanced
      2x16 I2C based LCD
      Advanced
      Fingerprint scanner Sensors and Actuators
      Basic
      Pi-Camera or USB Webcam for taking photos
      Basic
      PIR Infrared Motion Sensor
      Basic
      Soil Moisture Sensor
      Basic
      Rain Fall sensor
      Basic
      Relays connected to equipment such as water-pump/lights/ locks/ valves
      Basic
      CPU/Case/Graphic card temperature sensor
      Basic
      Photoresistor & LED or RGB LED with ADC module
      Advanced
      Infrared Digital Obstacle Avoidance Sensor
      Advanced
      Potentiometer & ADC module with LEDs or RGB LED
      Advanced
      Attitude Sensor MPU6050
      Advanced
      Hygrothermograph DHT11 sensor / Barometric Pressure Sensor
      Advanced
      Wind Direction & Speed sensors
      Advanced
      Ultrasonic Distance Sensors
      Advanced
      Motor with ADC control or PWM
      Advanced
      Servo Motor/s
      Advanced
      Pi-Camera or USB Webcam with Open-CV computer vision

    • @user-ut6dr9pb7l
      @user-ut6dr9pb7l หลายเดือนก่อน +1

      List at least 5 functionalities in total from Table 1 below (Minimum 2 of which must be advanced) for use in your project. Elements from both sections of the table (User Interface and Sensors and Actuators) must be included. Use of the same component is only allowed once, if the two components are complementary to each other and are going to be programmed separately.
      We need to choose atleast 5 things

    • @user-ut6dr9pb7l
      @user-ut6dr9pb7l หลายเดือนก่อน +1

      @@Waiduino My group and I already have chosen things can you help us pls?

  • @fkj7761
    @fkj7761 6 หลายเดือนก่อน +1

    Hi 7:57

    • @Waiduino
      @Waiduino  6 หลายเดือนก่อน +1

      Hi!!! Did you enjoy the video?

  • @user-ut6dr9pb7l
    @user-ut6dr9pb7l หลายเดือนก่อน +1

    boqo lol boqo no space for email

    • @Waiduino
      @Waiduino  หลายเดือนก่อน +1

      thanks! I’ll send an email when I get home

  • @ih8snow415
    @ih8snow415 5 หลายเดือนก่อน +1

    use this code if ur buzzer sound like radioactive sound
    "#define trigPin 9 // Broche de déclenchement du capteur à ultrasons
    #define echoPin 10 // Broche d'écho du capteur à ultrasons
    #define ledPin 13 // Broche de la LED
    #define buzzerPin 11 // Broche du buzzer
    void setup() {
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    pinMode(ledPin, OUTPUT);
    pinMode(buzzerPin, OUTPUT);
    Serial.begin(9600);
    }
    void loop() {
    long duration, distance;
    // Envoi d'une impulsion de déclenchement au capteur à ultrasons
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    // Lecture de la durée de l'impulsion d'écho
    duration = pulseIn(echoPin, HIGH);
    // Calcul de la distance en centimètres
    distance = (duration / 2) / 29.1;
    // Affichage de la distance dans le moniteur série
    Serial.print("Distance : ");
    Serial.print(distance);
    Serial.println(" cm");
    // Vérification de la distance et activation de la LED et du buzzer
    if (distance < 20) {
    digitalWrite(ledPin, HIGH); // Allume la LED
    tone(buzzerPin, 1000); // Active le buzzer à 1 kHz
    } else {
    digitalWrite(ledPin, LOW); // Éteint la LED
    noTone(buzzerPin); // Désactive le buzzer
    }
    delay(100); // Attente pour éviter les fausses détections
    }
    "

    • @Waiduino
      @Waiduino  5 หลายเดือนก่อน +1

      Thank you so much! I appreciate your input!! Do you use the Arduino often?

    • @ih8snow415
      @ih8snow415 5 หลายเดือนก่อน +1

      @@Waiduino yes sometimes

    • @Waiduino
      @Waiduino  5 หลายเดือนก่อน +1

      @@ih8snow415 Oh cool!! Are you new to Arduino and electronics?

  • @clobel55
    @clobel55 หลายเดือนก่อน +2

    extremely confusing

    • @Waiduino
      @Waiduino  หลายเดือนก่อน +1

      Thanks for your comment what did you find particularly confusing?

  • @fkj7761
    @fkj7761 6 หลายเดือนก่อน +1

    Hi

    • @Waiduino
      @Waiduino  6 หลายเดือนก่อน +1

      Hi, how are you?