Circuit Documentation
Summary of the Circuit
This circuit integrates an HC-SR04 Ultrasonic Sensor with an Arduino UNO microcontroller. The purpose of the circuit is to utilize the ultrasonic sensor to measure distances by emitting ultrasonic waves and detecting the reflected signal. The Arduino UNO is programmed to control the sensor and process the distance information.
Component List
HC-SR04 Ultrasonic Sensor
- Pins: VCC, TRIG, ECHO, GND
- Description: An ultrasonic ranging sensor that provides 2cm to 400cm non-contact measurement functionality with a ranging accuracy that can reach up to 3mm.
- Purpose: To measure the distance to an object by emitting ultrasonic pulses and detecting their reflections.
Arduino UNO
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0 to A5, SCL, SDA, AREF, D0 to D13
- Description: A microcontroller board based on the ATmega328P, with digital input/output pins, analog inputs, a USB connection for programming, and power management features.
- Purpose: To control the HC-SR04 Ultrasonic Sensor and process the distance measurements.
Wiring Details
HC-SR04 Ultrasonic Sensor
- VCC: Connected to the 5V output on the Arduino UNO.
- TRIG: Connected to digital pin D2 on the Arduino UNO.
- ECHO: Connected to digital pin D3 on the Arduino UNO.
- GND: Connected to the ground (GND) on the Arduino UNO.
Arduino UNO
- 5V: Provides power to the HC-SR04 Ultrasonic Sensor.
- D2: Sends trigger signal to the HC-SR04 Ultrasonic Sensor.
- D3: Receives echo signal from the HC-SR04 Ultrasonic Sensor.
- GND: Common ground for the circuit.
Documented Code
Arduino UNO Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
This code is a template for the Arduino UNO microcontroller. The setup() function is intended to contain initialization code that runs once when the microcontroller is powered on or reset. The loop() function is designed to contain the main logic of the program, which runs repeatedly as long as the microcontroller is powered.
The actual implementation of the code to control the HC-SR04 Ultrasonic Sensor and process the distance measurements will be added to these functions. The setup() function will typically initialize the sensor's trigger and echo pins, while the loop() function will handle the timing of the trigger signal, listen for the echo, and calculate the distance based on the time interval between sending and receiving the ultrasonic pulses.
