This circuit is designed to detect an event (such as the presence of an object) using an infrared (IR) sensor and provide an audible alert through a Piezo Buzzer. The Arduino UNO serves as the central processing unit, reading the output from the IR sensor and controlling the state of the Piezo Buzzer accordingly. When the IR sensor detects the specified event, the Arduino activates the buzzer.
// Code for Arduino UNO
int sensorPin = 2; // IR sensor OUT pin connected to Digital Pin 2
int buzzerPin = 8; // Piezo Buzzer pin connected to Digital Pin 8
int sensorValue = 0; // Variable to store the sensor output
void setup() {
pinMode(sensorPin, INPUT); // Set the sensor pin as input
pinMode(buzzerPin, OUTPUT); // Set the buzzer pin as output
}
void loop() {
sensorValue = digitalRead(sensorPin); // Read the sensor output
if (sensorValue == HIGH) {
// If the sensor detects the specified event (assuming HIGH means event detected)
digitalWrite(buzzerPin, HIGH); // Turn on the buzzer
} else {
digitalWrite(buzzerPin, LOW); // Turn off the buzzer
}
}
Filename: sketch.ino
This code is written for the Arduino UNO microcontroller. It initializes the sensor and buzzer pins, reads the sensor output in the main loop, and turns the buzzer on or off based on the sensor reading. The assumption here is that a HIGH signal from the IR sensor indicates the detection of the specified event.