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.
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
Buen día, se puede agregar un buzzer
¿'
@@ericknova2989 Hola, no hablo muy bien español. Sí, puedes agregar un buzzer. Puedo hacer un vídeo sobre eso si estás interesado.
@@Waiduino Hola, si, seria interesante agregar un buzzer que se active con el código que creaste.
@@ericknova2989 Haré mi próximo video sobre cómo agregar un buzzer para este proyecto. Gracias por tu comentario.
@@ericknova2989 Se acaba de publicar un nuevo vídeo sobre el sensor y el buzzer. ¡Disfrutar! Gracias por tu comentario
Yo the channel owner is legend for replying to all comments most TH-camrs dont do that
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!!
Hello just wanted to say thanks, I tried this in my class, it was my first time using ultrasonic and it worked💗
Yea of course! Thanks so much for your kind words.
Creative video, thank you :)
Thank you!! Did you build the project?
Very well explained thanks
Thank you so much! Were you able to make the circuit?
endless thanks
No problem! Glad you enjoyed and learned something. Did you have to make it for a school project?
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 ???
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?
What was the resistance of the resistor you used? And how did you wire the leds, and the wires next to the led?
oh wait nvm i think i got it.
Sounds good thanks for commenting! Were you able to create the circuit?
@@Waiduino it works thanks.
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
Sure which motors are you interested in? Like servo?
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.
Hola! Gracias por tu comentario. ¿Quieres conectar el arduino a un teléfono?
only one light blink you know why i pretty sure i put it together right
You copied the code exactly, right? What pins is each individual LED connected to. Make sure they are securely in.
Can we do this with uno and hc-sr04???
Yep! If I am not mistaken, I used the hc-sr04 in my video as well as the uno. Thanks for your comment!
What is the resister number you used bro?
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
how many ohms resistor did you use
Hi! It should be 330 ohms, I’m not entirely sure. The lower resistance, the brighter your LED is gonna be. Hope this helps!
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?
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
@@Waiduino ok
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
Does that work? Let me know
@@Waiduino it doesn't
hello how to give connections for led positive and negative and resistor?
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!
@@Waiduino oh thank you
@@mvsaikartheek633 Sure no problem! Let me know if you have any other questions.
@@Waiduino okay 👍
Yo I am new to arduino so could you tell me what app you use to put the code into the thing
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!!
@@Waiduino Thank you 😊
@@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?
@@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)
@@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!
Can u tell me the number of the risistor and the wites
I used a 1k ohm resistor. The higher resistance, the less bright your LED will be. What is your question about the wires?
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
the led is not lighting up how matter I try
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?
hey their whenever i connect to 5V my arduino shuts off plz help ASAP thanks
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?
@@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
@@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?
are you open to innovation project. ?
Yea definitely! I have been working on a few but they take really long to finish them.
Also don’t forget to check out my other videos with cool projects and different Arduino modules!
Step1: Disconect Power from Arduino
Oh I forgot to add that to my video 😅😅. Did you make the project?
It doesn't let me send an email here I don't know why
No give me your email address so I can send you an email
@@Waiduino boqo lol boqo no space for email
@@Waiduino I couldn't send the whole email since it didn't let me and no space and no numbers
@@Waiduino Did you find it?
It's a distance sensor ig
Yea you could think about it like that. Did you get a a chance to make it?
@Waiduino yes long ago, btw . Motion sensing is different from distance sensing i think
@@naughtyboys2381 Thanks for pointing that out, your are correct. Thank you!
Hi
😂😂 Hi! Are you interested in Arduino
Awesome video bruh can you help pls? thanks!
I’m glad you enjoyed the video! I can help, what seems to be the issue?
@@Waiduino Heyy thank you! Do you have discord account?
@@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
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
@@Waiduino My group and I already have chosen things can you help us pls?
Hi 7:57
Hi!!! Did you enjoy the video?
boqo lol boqo no space for email
thanks! I’ll send an email when I get home
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
}
"
Thank you so much! I appreciate your input!! Do you use the Arduino often?
@@Waiduino yes sometimes
@@ih8snow415 Oh cool!! Are you new to Arduino and electronics?
extremely confusing
Thanks for your comment what did you find particularly confusing?
Hi
Hi, how are you?