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 device that uses high-frequency sound waves to measure distances or detect objects in its surroundings. It operates by emitting ultrasonic waves and measuring the time it takes for the echo to return after bouncing off an object. This time-of-flight measurement is then used to calculate the distance to the object.

Common applications of the ULTRASONIC sensor include:

  • Obstacle detection in robotics
  • Distance measurement in automation systems
  • Liquid level sensing
  • Parking assistance systems in vehicles
  • Proximity detection in security systems

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

Technical Specifications

The following are the key technical details of the ULTRASONIC sensor:

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

Pin Configuration and Descriptions

The ULTRASONIC sensor typically has four pins, as described below:

Pin Name Description
VCC Power supply pin (5V DC)
GND Ground pin
TRIG Trigger pin: Used to send the ultrasonic pulse
ECHO Echo pin: Outputs a pulse proportional to distance

Usage Instructions

How to Use the ULTRASONIC Sensor in a Circuit

  1. Power the Sensor: Connect the VCC pin to a 5V power source and the GND pin to ground.
  2. Trigger the Sensor: Send a 10 µs HIGH pulse to the TRIG pin to initiate a measurement.
  3. Read the Echo: Measure the duration of the HIGH pulse on the ECHO pin. This duration corresponds to the time taken for the ultrasonic wave to travel to the object and back.
  4. Calculate Distance: Use the formula below to calculate the distance: [ \text{Distance (cm)} = \frac{\text{Time (µs)} \times 0.034}{2} ] The factor 0.034 represents the speed of sound in cm/µs, and the division by 2 accounts for the round trip of the wave.

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 ultrasonic noise, as this may interfere with measurements.
  • Place the sensor at an appropriate height and angle for accurate detection.
  • Use decoupling capacitors near the power pins to reduce noise in the circuit.

Example Code for Arduino UNO

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

// Define pins for the ULTRASONIC sensor
const int trigPin = 9; // TRIG pin connected to digital pin 9
const int echoPin = 10; // ECHO pin connected to digital pin 10

void setup() {
  pinMode(trigPin, OUTPUT); // Set TRIG pin as output
  pinMode(echoPin, INPUT);  // Set ECHO pin as input
  Serial.begin(9600);       // Initialize serial communication
}

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

  // Measure the duration of the HIGH pulse on the ECHO pin
  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");

  delay(500); // Wait for 500 ms before the next measurement
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Output or Incorrect Readings:

    • Ensure the sensor is powered correctly (5V to VCC and GND connected).
    • Verify the connections to the TRIG and ECHO pins.
    • Check for loose wires or poor soldering.
  2. Inconsistent Measurements:

    • Ensure the target object is within the sensor's range (2 cm to 400 cm).
    • Avoid using the sensor in environments with high humidity or temperature variations, as these can affect the speed of sound.
  3. Interference from Nearby Sensors:

    • If multiple ULTRASONIC sensors are used, trigger them sequentially to avoid cross-interference.

FAQs

Q: Can the ULTRASONIC sensor detect transparent objects?
A: The sensor may struggle to detect transparent objects like glass, as ultrasonic waves may pass through or reflect unpredictably.

Q: What is the maximum angle of detection?
A: The sensor typically has a detection angle of about 15 degrees. Ensure objects are within this cone for accurate measurements.

Q: Can the sensor be used outdoors?
A: While the sensor can be used outdoors, ensure it is protected from water and extreme environmental conditions to prevent damage.

By following this documentation, users can effectively integrate the ULTRASONIC sensor into their projects and troubleshoot common issues.