Arduino UNO-Based Dual Ultrasonic Sensor Distance Measurement with Piezo Speaker Alert
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit involves an Arduino UNO microcontroller interfacing with two HC-SR04 Ultrasonic Sensors, an Electrolytic Capacitor, and a Piezo Speaker. The Arduino UNO is used to control and read data from the sensors and to drive the Piezo Speaker. The Electrolytic Capacitor is used for signal conditioning.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Electrolytic Capacitor
- Description: A polarized capacitor with a capacitance of 47 µF.
- Pins: -, +
Piezo Speaker
- Description: A small speaker that produces sound when a voltage is applied.
- Pins: pin1, pin2
HC-SR04 Ultrasonic Sensor
- Description: A sensor that measures distance by using ultrasonic waves.
- Pins: VCC, TRIG, ECHO, GND
Wiring Details
Arduino UNO
- 5V: Connected to VCC of both HC-SR04 Ultrasonic Sensors.
- GND: Connected to GND of both HC-SR04 Ultrasonic Sensors and pin1 of the Piezo Speaker.
- D8: Connected to the + pin of the Electrolytic Capacitor.
- D9: Connected to the TRIG pin of the first HC-SR04 Ultrasonic Sensor.
- D10: Connected to the ECHO pin of the first HC-SR04 Ultrasonic Sensor.
- D11: Connected to the TRIG pin of the second HC-SR04 Ultrasonic Sensor.
- D12: Connected to the ECHO pin of the second HC-SR04 Ultrasonic Sensor.
Electrolytic Capacitor
- +: Connected to D8 of the Arduino UNO.
- -: Connected to pin2 of the Piezo Speaker.
Piezo Speaker
- pin1: Connected to GND of the Arduino UNO.
- pin2: Connected to the - pin of the Electrolytic Capacitor.
HC-SR04 Ultrasonic Sensor (First Sensor)
- VCC: Connected to 5V of the Arduino UNO.
- GND: Connected to GND of the Arduino UNO.
- TRIG: Connected to D9 of the Arduino UNO.
- ECHO: Connected to D10 of the Arduino UNO.
HC-SR04 Ultrasonic Sensor (Second Sensor)
- VCC: Connected to 5V of the Arduino UNO.
- GND: Connected to GND of the Arduino UNO.
- TRIG: Connected to D11 of the Arduino UNO.
- ECHO: Connected to D12 of the Arduino UNO.
Code Documentation
Arduino UNO Code
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
This code is a basic template for the Arduino UNO. The setup() function is where you initialize your components and settings, and the loop() function is where the main logic of your program runs repeatedly.