Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use ULTASONIC: Examples, Pinouts, and Specs

Image of ULTASONIC
Cirkit Designer LogoDesign with ULTASONIC in Cirkit Designer

Introduction

The ultrasonic sensor is a versatile electronic component that uses high-frequency sound waves to measure distances or detect objects. It operates by emitting ultrasonic pulses and calculating the time it takes for the echo to return after bouncing off an object. This time-of-flight measurement allows for precise distance calculations, making the ultrasonic sensor a popular choice in a wide range of applications.

Explore Projects Built with ULTASONIC

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino UNO-Based Ultrasonic Sensor and Relay-Controlled Audio System
Image of BT Speaker: A project utilizing ULTASONIC in a practical application
This circuit features an Arduino UNO microcontroller interfaced with two HC-SR04 ultrasonic sensors for distance measurement, a 4-channel relay module for controlling external devices, and an EZ-SFX amplifier connected to two loudspeakers for audio output. The system is powered by a Polymer Lithium Ion Battery and includes basic setup and loop code for the Arduino.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO-Based Obstacle Avoidance Robot with Ultrasonic Sensors and L298N Motor Driver
Image of Measure Temperature a: A project utilizing ULTASONIC in a practical application
This circuit is a robotic system controlled by an Arduino UNO, featuring three HC-SR04 ultrasonic sensors for obstacle detection and an L298N motor driver to control two DC motors. The system is powered by a 7.4V battery and includes a rocker switch for power control, with the Arduino code set up to read sensor data and manage motor operations.
Cirkit Designer LogoOpen Project in Cirkit Designer
Interactive Touch and Motion Sensor System with Bela Board and OLED Display
Image of GIZMO Teaset: A project utilizing ULTASONIC in a practical application
This circuit integrates a Bela Board with various sensors and actuators, including a TRILL CRAFT touch sensor, an ADXXL335 accelerometer, a vibration motor, and a loudspeaker. The Bela Board processes input from the touch sensor and accelerometer, and controls the vibration motor and loudspeaker, while an OLED display provides visual feedback.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Mega 2560-Based Obstacle-Avoiding Robot with Ultrasonic Sensors and BTS7960 Motor Drivers
Image of MEGA: A project utilizing ULTASONIC in a practical application
This circuit is a robotic system controlled by an Arduino Mega 2560, which uses multiple ultrasonic sensors for obstacle detection and potentiometers for setting movement limits. It drives four 775 motors through two BTS7960 motor drivers, with limit switches and a rocker switch for additional control inputs.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with ULTASONIC

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of BT Speaker: A project utilizing ULTASONIC in a practical application
Arduino UNO-Based Ultrasonic Sensor and Relay-Controlled Audio System
This circuit features an Arduino UNO microcontroller interfaced with two HC-SR04 ultrasonic sensors for distance measurement, a 4-channel relay module for controlling external devices, and an EZ-SFX amplifier connected to two loudspeakers for audio output. The system is powered by a Polymer Lithium Ion Battery and includes basic setup and loop code for the Arduino.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Measure Temperature a: A project utilizing ULTASONIC in a practical application
Arduino UNO-Based Obstacle Avoidance Robot with Ultrasonic Sensors and L298N Motor Driver
This circuit is a robotic system controlled by an Arduino UNO, featuring three HC-SR04 ultrasonic sensors for obstacle detection and an L298N motor driver to control two DC motors. The system is powered by a 7.4V battery and includes a rocker switch for power control, with the Arduino code set up to read sensor data and manage motor operations.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of GIZMO Teaset: A project utilizing ULTASONIC in a practical application
Interactive Touch and Motion Sensor System with Bela Board and OLED Display
This circuit integrates a Bela Board with various sensors and actuators, including a TRILL CRAFT touch sensor, an ADXXL335 accelerometer, a vibration motor, and a loudspeaker. The Bela Board processes input from the touch sensor and accelerometer, and controls the vibration motor and loudspeaker, while an OLED display provides visual feedback.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of MEGA: A project utilizing ULTASONIC in a practical application
Arduino Mega 2560-Based Obstacle-Avoiding Robot with Ultrasonic Sensors and BTS7960 Motor Drivers
This circuit is a robotic system controlled by an Arduino Mega 2560, which uses multiple ultrasonic sensors for obstacle detection and potentiometers for setting movement limits. It drives four 775 motors through two BTS7960 motor drivers, with limit switches and a rocker switch for additional control inputs.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • Obstacle detection in robotics and autonomous vehicles
  • Distance measurement in industrial automation
  • Level sensing in liquid tanks
  • Proximity detection in security systems
  • Gesture recognition in interactive devices

Technical Specifications

Below are the key technical details of a typical ultrasonic sensor (e.g., HC-SR04):

Parameter Value
Operating Voltage 5V DC
Operating Current 15 mA
Operating Frequency 40 kHz
Measuring Range 2 cm to 400 cm
Accuracy ±3 mm
Trigger Input Signal 10 µs TTL pulse
Echo Output Signal Pulse width proportional to distance
Dimensions 45 mm x 20 mm x 15 mm

Pin Configuration and Descriptions

Pin Name Pin Number Description
VCC 1 Power supply pin (5V DC)
Trig 2 Trigger pin: Sends the ultrasonic pulse
Echo 3 Echo pin: Outputs a pulse proportional to distance
GND 4 Ground pin

Usage Instructions

How to Use the Ultrasonic Sensor in a Circuit

  1. Connect the Pins:

    • Connect the VCC pin to a 5V power source.
    • Connect the GND pin to the ground of the circuit.
    • Connect the Trig pin to a digital output pin of your microcontroller.
    • Connect the Echo pin to a digital input pin of your microcontroller.
  2. Trigger the Sensor:

    • Send a 10 µs HIGH pulse to the Trig pin to initiate the ultrasonic pulse.
  3. Measure the Echo:

    • Measure the duration of the HIGH pulse on the Echo pin. This duration is proportional to the distance of the object.
  4. Calculate the Distance:

    • Use the formula:
      [ \text{Distance (cm)} = \frac{\text{Pulse Duration (µs)} \times 0.034}{2} ] The factor 0.034 accounts for the speed of sound (343 m/s) in air.

Important Considerations and Best Practices

  • Ensure there are no obstructions between the sensor and the target object.
  • Avoid using the sensor in environments with high noise or vibrations, as these can interfere with measurements.
  • Use a capacitor (e.g., 10 µF) across the VCC and GND pins to stabilize the power supply.
  • For best results, ensure the target object has a flat, hard surface to reflect the ultrasonic waves effectively.

Example Code for Arduino UNO

Below is an example of how to use the ultrasonic sensor with an Arduino UNO:

// Define the pins for the ultrasonic sensor
const int trigPin = 9; // Trigger pin connected to digital pin 9
const int echoPin = 10; // Echo pin connected to digital pin 10

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(9600);
  
  // Set the trigPin as an output and echoPin as an input
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  // Send a 10 µs HIGH pulse to the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Measure the duration of the HIGH pulse on the echoPin
  long duration = pulseIn(echoPin, HIGH);

  // Calculate the distance in cm
  float distance = (duration * 0.034) / 2;

  // Print the distance to the Serial Monitor
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");

  // Wait for a short period before the next measurement
  delay(500);
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Output or Incorrect Readings:

    • Cause: Loose or incorrect wiring.
    • Solution: Double-check all connections, ensuring the pins are connected to the correct microcontroller pins.
  2. Unstable or Fluctuating Measurements:

    • Cause: Electrical noise or unstable power supply.
    • Solution: Add a decoupling capacitor (e.g., 10 µF) across the VCC and GND pins.
  3. Sensor Not Detecting Objects:

    • Cause: Target object is too far, too close, or has a poor reflective surface.
    • Solution: Ensure the object is within the sensor's range (2 cm to 400 cm) and has a flat, hard surface.
  4. Echo Pin Always LOW:

    • Cause: Trigger signal not sent correctly.
    • Solution: Verify that the Trig pin is receiving a 10 µs HIGH pulse.

FAQs

  • Q: Can the ultrasonic sensor detect transparent objects?
    A: No, the sensor may struggle to detect transparent or soft objects as they do not reflect ultrasonic waves effectively.

  • Q: Can I use the sensor with a 3.3V microcontroller?
    A: Yes, but you may need a logic level shifter for the Echo pin to avoid damaging the microcontroller.

  • Q: What is the maximum angle of detection?
    A: The sensor typically has a detection angle of about 15 degrees.

  • Q: Can the sensor work outdoors?
    A: While it can work outdoors, environmental factors like wind, temperature, and rain may affect its performance.