Circuit Documentation
Summary of the Circuit
This circuit consists of an Arduino UNO microcontroller board interfaced with an HC-SR04 Ultrasonic Sensor. The Arduino UNO is responsible for controlling the sensor and processing the distance measurements. The HC-SR04 Ultrasonic Sensor is used to measure distances by emitting ultrasonic waves and detecting the reflection from nearby objects.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13.
- Purpose: Acts as the central processing unit for the circuit, controlling the HC-SR04 Ultrasonic Sensor and processing the data.
HC-SR04 Ultrasonic Sensor
- Description: An ultrasonic distance sensor capable of measuring distances from 2cm to 400cm.
- Pins: VCC, TRIG, ECHO, GND.
- Purpose: Measures the distance to objects by emitting and receiving ultrasonic waves.
Wiring Details
Arduino UNO
- 5V: Provides power to the HC-SR04 Ultrasonic Sensor.
- GND: Common ground with the HC-SR04 Ultrasonic Sensor.
- D10: Connected to the TRIG pin of the HC-SR04 Ultrasonic Sensor to trigger distance measurements.
- D9: Connected to the ECHO pin of the HC-SR04 Ultrasonic Sensor to receive the distance measurement signal.
HC-SR04 Ultrasonic Sensor
- VCC: Connected to the 5V pin of the Arduino UNO for power.
- GND: Connected to the GND pin of the Arduino UNO for a common ground.
- TRIG: Connected to the D10 pin of the Arduino UNO to receive trigger signals for distance measurement.
- ECHO: Connected to the D9 pin of the Arduino UNO to send the distance measurement signal.
Documented Code
void setup() {
// Initialize the sensor's TRIG and ECHO pins
pinMode(10, OUTPUT); // TRIG pin
pinMode(9, INPUT); // ECHO pin
}
void loop() {
// Trigger the sensor to start the measurement
digitalWrite(10, LOW);
delayMicroseconds(2);
digitalWrite(10, HIGH);
delayMicroseconds(10);
digitalWrite(10, LOW);
// Read the time duration of the returned echo signal
long duration = pulseIn(9, HIGH);
// Calculate the distance based on the duration
long distance = duration * 0.034 / 2;
// Output the distance
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Wait before the next measurement
delay(1000);
}
Note: The provided code is a basic template for initializing the pins and reading the distance from the HC-SR04 Ultrasonic Sensor. The actual implementation may require additional code for complete functionality.
