How to do ultrasonic sensor alarm with Arduino
Diagram Code // defines pins numbers const int trigPin = 9; const int echoPin = 10; const int buzzer = 11; const int ledPin = 13; // Project by - Be innovative with Prasad // title - ultrasonic sensor project with buzzer and Arduino // defines variables long duration; int distance; int safetyDistance; void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input pinMode(buzzer, OUTPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600); // Starts the serial communication } void loop() { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH sta...