Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Ultrasonic Distance Measurement

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Ultrasonic Distance Measurement

Circuit Documentation

Summary of the Circuit

This circuit integrates an Arduino UNO microcontroller board with an HC-SR04 Ultrasonic Sensor. The purpose of this setup is to utilize the ultrasonic sensor to measure distances, which is a common application in robotics and automation for object detection or range finding. The Arduino UNO serves as the control unit to process the signals from the HC-SR04 sensor.

Component List

Arduino UNO

HC-SR04 Ultrasonic Sensor

Wiring Details

Arduino UNO

HC-SR04 Ultrasonic Sensor

Documented Code

The following code is intended to be uploaded to the Arduino UNO microcontroller to interface with the HC-SR04 Ultrasonic Sensor. The code is structured with a setup() function to initialize the sensor and a loop() function to continuously measure and process the distance data.

void setup() {
  // Initialize the HC-SR04 Ultrasonic Sensor
  pinMode(2, OUTPUT); // TRIG pin as output
  pinMode(3, INPUT);  // ECHO pin as input
}

void loop() {
  // Trigger the ultrasonic pulse
  digitalWrite(2, LOW);
  delayMicroseconds(2);
  digitalWrite(2, HIGH);
  delayMicroseconds(10);
  digitalWrite(2, LOW);

  // Read the echo pulse
  long duration = pulseIn(3, HIGH);
  long distance = duration * 0.034 / 2; // Calculate the distance

  // Process the distance and implement your logic here

  delay(100); // Delay between measurements
}

Note: The provided code is a template and requires further implementation for specific applications. The loop() function should include logic to handle the distance data, such as triggering events or actions when certain distance thresholds are met.