-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1dbb376
commit 1670d49
Showing
7 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
int trigger_pin = 2; | ||
int echo_pin = 3; | ||
//int buzzer_pin = 10; | ||
int time; | ||
int distance; | ||
void setup() | ||
{ | ||
Serial.begin (9600); | ||
pinMode (trigger_pin, OUTPUT); | ||
pinMode (echo_pin, INPUT); | ||
// pinMode (buzzer_pin, OUTPUT); | ||
} | ||
void loop() | ||
{ | ||
digitalWrite (trigger_pin, HIGH); | ||
delayMicroseconds (10); | ||
digitalWrite (trigger_pin, LOW); | ||
time = pulseIn (echo_pin, HIGH); | ||
distance = (time * 0.034) / 2; | ||
|
||
if (distance <= 10) | ||
{ | ||
Serial.println ("Very close to sensor! "); | ||
// digitalWrite (buzzer_pin, HIGH); | ||
delay (500); | ||
} | ||
else { | ||
Serial.println ("Obstacle detected"); | ||
Serial.print (" Distance = "); | ||
Serial.println (distance); | ||
// digitalWrite (buzzer_pin, LOW); | ||
delay (500); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
|
||
Obstacle detector - in this project, we made an obstacle detector using arduino and ultra sonic sensor.when we start our porgram, our ultrasonic sensor will be powered on and when any object comes in its range, then we will display "Obstacle detected" along with the distance of object from the sensor. |