aru_poonia
Published © GPL3+

Detecting Obstacles and Warn using Arduino-Ultrasonic

It detect the obstacle which is being around it and play on the buzzer.

IntermediateShowcase (no instructions)973
Detecting Obstacles and Warn using Arduino-Ultrasonic

Things used in this project

Hardware components

Resistor 100 ohm
Resistor 100 ohm
×3
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
LED (generic)
LED (generic)
×1
Buzzer, Piezo
Buzzer, Piezo
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long

Story

Read more

Custom parts and enclosures

Project

Schematics

Schematic/ Hardware project

Code

Buzzer CODE

Arduino
int ledPIN = 7;
int speakerPIN = 9;
int trigPIN = 13;
int echoPIN = 11;
boolean buttonOn = false;
void setup() {
  // put your setup code here, to run once:
  pinMode(ledPIN, OUTPUT);
  pinMode(echoPIN, INPUT);
  pinMode(trigPIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {

  long duration, distance;
  digitalWrite(trigPIN,HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPIN,LOW);
  duration = pulseIn(echoPIN,HIGH);
  distance = (duration/2)/29.1;
  Serial.print(distance);
  Serial.println("CM");
  delay(10);
 
  if (distance < 10) {
    digitalWrite(ledPIN, HIGH);
    tone(speakerPIN,1000);
  }
  else {
    digitalWrite(ledPIN, LOW);
    noTone(speakerPIN);
  }
}

Credits

aru_poonia
0 projects • 0 followers

Comments