Detecting Obstacles and Warning – Arduino and Ultrasonic

ABOUT THIS PROJECT

This is tutorial to help you understand ultrasonic and buzzer and go deeper into learning Arduino, follow these steps and give me feedback.

HARDWARE REQUIREMENT

  1. ARDUINIO UNO
  2. ULTRASONIC SENSOR HC-SR04
  3. BREADBOARD
  4. BUZZER
  5. JUMPER WIRES for making connections.

SOFTWARE REQUIREMENT

  1. ARDUINO IDE

SCHEMATIC

ultrasonic with buzzer_bb

SOURCE CODE ARDUINO :

int const trigPin = 10;
int const echoPin = 9;
int const buzzPin = 2;

void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzPin, OUTPUT);
}

void loop()
{
int duration, distance;
digitalWrite(trigPin, HIGH);
delay(1);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance <= 50 && distance >= 0) {
digitalWrite(buzzPin, HIGH);
} else {
digitalWrite(buzzPin, LOW);
}
delay(60);
}

FOR ANY QUERY OR INFORMATION RELATED THE PROJECT PLEASE REGISTER TECEX (LINK GIVEN BELOW)

REGISTER TECEX

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s