Source Code: create.arduino.cc/editor/mertarduinotech/b7022e05-f709-4003-b2a7-5c487ee25007/preview Recommended Items: Use Your Muscles in Project - amzn.to/3wdL45C 37 Sensor & Module Packages - amzn.to/3m66WeQ Try this Robot Arm - amzn.to/3fq8DCl Best Resin 3D Printer - amzn.to/39tY8KB Arduino Compatible Kits - bit.ly/2J2AFF7 Banggood Spring Sale - bit.ly/3slMbOn
3 years later and we are still building this. I set safetyDistance to 25. With only LED and no buzzer. Detects my cat coming in the room. Pretty cool - I guess!
If anyone has any problems to get the code...just copy mine. // defines pins numbers const int trigPin = 9; const int echoPin = 10; const int buzzer = 11; const int ledPin = 13; // defines 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 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; safetyDistance = distance; if (safetyDistance
very interesting , I change the LED to a servo motor, it works .... good According to your code information , it means can do anything when change the led or buzzer, thank you !
Hello. There are already a lot of these examples on youtube. In your circuit the lights are either on or off. The sound either squeaks or it doesn't. I wish you had made a circuit where the intensity of sound and light increases as you get closer. :(
// defines pins numbers const int trigPin = 9; const int echoPin = 10; const int buzzer = 11; const int ledPin = 13; // defines 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 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; safetyDistance = distance; if (safetyDistance
Nice Job Ur Great with the tutorial which is very understandable and the code. One problem is that when I went to the source code to look it took me to ur website with no code
Hey! I love this project tysm. But I was wondering How would I increse/decrese the range so that it will turn buzzer on when someone is more farther away? Thanks!
Just look the code, he configured the "Safe Distance to 5", if you want to make it in different length just change the safe distance to a greater number
do the trig and echo pins need to be on a PWM signal for them to work? I am doing a project on the Arduino mega and using 3 of these sensors, but all of the PWM pins are being used on motor drivers. Love your videos. Best Arduino channel. Keep up the good work!
Mert Thanks for your videos tutorials. .can you please do ir remote control car with old fashion motor shield no who you solder the pins up like the video number 2
Hi! I tried to do 2 things together, Like a bell ring (you push the button and hear the buzzer rings) and LDR+3colorLED. But when I press the button when there is no light it rings only when the loop of LED is over. Why is it so?
why do when i check the monitor to see the distance every time it put the disance then a 0 again and again and that makes the buzzer make noise even when the is nothing infront of the sensor