#include <Ultrasonic.h>
const int TRIGGER_PIN = 14;
const int ECHO_PIN = 25;
const int ALERT_THRESHOLD = 50;
const int BUZZER_PIN = 12;
Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN);
int distance;
void setup() {
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
distance = ultrasonic.read();
if (distance < ALERT_THRESHOLD) {
alertUser();
}
delay(100); // Adjust delay as needed
}
void alertUser() {
tone(BUZZER_PIN, 1000); // Sound alert
delay(500); // Alert duration
noTone(BUZZER_PIN); // Stop alert
}