#define trigPin 13
#define echoPin 12
#define motor 7
#define buzzer 6
void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(motor, OUTPUT);
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;
if (distance < 70) // This is where checking the distance you can change the value
{
digitalWrite(motor,HIGH); // When the the distance below 100cm
digitalWrite(buzzer,HIGH);
} else
{
digitalWrite(motor,LOW); // when greater than 100cm
digitalWrite(buzzer,LOW);
} delay(500);
}
16 Comments
Hello bro,,,, kya ap muje srif code de sagteho plz
ReplyDeleteOkay message me on insta username innovative ideas yt
DeletePlease give me the code only
DeleteBhai maine bhi dm kra h plz reply mujhe parso submit krrna h
DeleteBhaiya plese Arduino mini ka bhi coonection samza do please
ReplyDeleteCan you give me the code only file?
ReplyDeleteBhai code kaha Hai mill
ReplyDeletenahi Raha hai
Msg me on Instagram
DeleteNOTHING IS WORKING
ReplyDeleteBhai buzza ki jangha vibration moter fit kare to coding me kya change aaya ga
ReplyDeleteKuch nhi bs positive wali wire vibration motor ki buzzer ki positive wali wire ki jagah lga dena
DeletePlease give me a circuit diagram
ReplyDeleteVai moje diagram or cobe place?
ReplyDeleteCode error bata raha hai
ReplyDeleteKya karu
Thanks a lot, for know my mistakes
ReplyDeletehello bro can u provide code only
ReplyDelete