Arduino code:
#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
Sir u are great thankssss sir
ReplyDeleteMost welcome
ReplyDeleteSir please give Arduino code away 4 mtr
ReplyDeleteHow can i copy it
ReplyDeletewhat is the motor variable in this project stand for? Please help!!
ReplyDeleteSir please give code of 3 meter
ReplyDeleteSir I am not able to understand pls anyone explain me it's urgent it's my project
ReplyDeletePls provide eme your WhatsApp number and guide me pls I want help
Please say how to do and enter the code
DeleteSir in which app we have to do this and how
ReplyDeleteSir I can't understand that please explain me 🥺🥺
ReplyDeleteSir I want to make just opposite of this project can you make for me please 🙏
ReplyDeleteSir I am getting error like this
ReplyDeleteArduino: 1.8.17 Hourly Build 2021/09/06 02:33 (Windows 10), Board: "Arduino Uno"
sketch_sep19a:63:19: error: stray '\302' in program
if (distance < 70) // This is where checking the distance you can change the value
^
sketch_sep19a:63:20: error: stray '\240' in program
if (distance < 70) // This is where checking the distance you can change the value
^
sketch_sep19a:63:22: error: stray '\302' in program
if (distance < 70) // This is where checking the distance you can change the value
^
sketch_sep19a:63:23: error: stray '\240' in program
if (distance < 70) // This is where checking the distance you can change the value
^
sketch_sep19a:63:25: error: stray '\302' in program
if (distance < 70) // This is where checking the distance you can change the value
^
sketch_sep19a:63:26: error: stray '\240' in program
if (distance < 70) // This is where checking the distance you can change the value
^
sketch_sep19a:69:26: error: stray '\302' in program
digitalWrite(motor,HIGH); // When the the distance below 100cm
^
sketch_sep19a:69:27: error: stray '\240' in program
digitalWrite(motor,HIGH); // When the the distance below 100cm
^
sketch_sep19a:69:29: error: stray '\302' in program
digitalWrite(motor,HIGH); // When the the distance below 100cm
^
sketch_sep19a:69:30: error: stray '\240' in program
digitalWrite(motor,HIGH); // When the the distance below 100cm
^
sketch_sep19a:81:25: error: stray '\302' in program
digitalWrite(motor,LOW); // when greater than 100cm
^
sketch_sep19a:81:26: error: stray '\240' in program
digitalWrite(motor,LOW); // when greater than 100cm
^
sketch_sep19a:81:28: error: stray '\302' in program
digitalWrite(motor,LOW); // when greater than 100cm
^
sketch_sep19a:81:29: error: stray '\240' in program
digitalWrite(motor,LOW); // when greater than 100cm
^
sketch_sep19a:81:31: error: stray '\302' in program
digitalWrite(motor,LOW); // when greater than 100cm
^
sketch_sep19a:81:32: error: stray '\240' in program
digitalWrite(motor,LOW); // when greater than 100cm
^
C:\Users\DELL\AppData\Local\Temp\arduino_modified_sketch_25701\sketch_sep19a.ino: In function 'void setup()':
sketch_sep19a:16:1: error: a function-definition is not allowed here before '{' token
{
^
sketch_sep19a:36:1: error: a function-definition is not allowed here before '{' token
{
^
sketch_sep19a:92:13: error: a function-definition is not allowed here before '{' token
void loop() {
^
sketch_sep19a:95:1: error: expected '}' at end of input
}
^
exit status 1
stray '\302' in program
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Pls say why
Pls help me
DeletePls
DeleteSir plz call me 6202957385
ReplyDeleteSir its is working ,i have done my programming and there is no any mistake
ReplyDelete