

The US-100 is an ultrasonic distance sensor designed to measure distances by emitting ultrasonic waves and calculating the time it takes for the echo to return. This sensor is widely used in robotics, automation, and IoT applications for tasks such as obstacle detection, distance measurement, and object tracking. Its versatility and ease of use make it a popular choice for both hobbyists and professionals.








The US-100 sensor offers both serial and pulse-width modulation (PWM) modes for distance measurement, making it highly adaptable to various applications.
The US-100 sensor has 4 pins, as described in the table below:
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (2.4V to 5.5V DC). |
| 2 | Trig/TX | Trigger pin for PWM mode or TX pin for serial communication. |
| 3 | Echo/RX | Echo pin for PWM mode or RX pin for serial communication. |
| 4 | GND | Ground connection. |
Note: The mode of operation (PWM or serial) is determined by the connection setup. If the Echo pin is left unconnected, the sensor operates in serial mode by default.
0x55) to request a distance reading.// US-100 Ultrasonic Distance Sensor - PWM Mode Example
// This code measures distance using the US-100 sensor in PWM mode
// and displays the result in the Serial Monitor.
#define TRIG_PIN 9 // Define the Trig pin
#define ECHO_PIN 10 // Define the Echo pin
void setup() {
pinMode(TRIG_PIN, OUTPUT); // Set Trig pin as output
pinMode(ECHO_PIN, 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(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Measure the duration of the HIGH pulse on the Echo pin
long duration = pulseIn(ECHO_PIN, 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 500ms before the next measurement
}
// US-100 Ultrasonic Distance Sensor - Serial Mode Example
// This code reads distance data from the US-100 sensor in serial mode
// and displays the result in the Serial Monitor.
#define RX_PIN 10 // Define the RX pin for the sensor
#define TX_PIN 11 // Define the TX pin for the sensor
#include <SoftwareSerial.h>
SoftwareSerial us100(RX_PIN, TX_PIN); // Create a SoftwareSerial object
void setup() {
Serial.begin(9600); // Initialize serial communication
us100.begin(9600); // Initialize the US-100 sensor at 9600 baud
}
void loop() {
us100.write(0x55); // Send the command to request a distance reading
delay(100); // Wait for the sensor to process the command
if (us100.available() >= 2) { // Check if at least 2 bytes are available
int highByte = us100.read(); // Read the high byte
int lowByte = us100.read(); // Read the low byte
int distance = (highByte << 8) + lowByte; // Combine the bytes into a distance value
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" mm");
}
delay(500); // Wait for 500ms before the next measurement
}
No Output or Incorrect Readings:
Unstable Measurements:
Serial Communication Not Working:
Q: Can the US-100 measure distances below 2cm?
A: No, the minimum measurable distance is 2cm. Objects closer than this may not be detected accurately.
Q: How do I switch between PWM and serial modes?
A: The mode is determined by the connection setup. Leave the Echo pin unconnected for serial mode, or connect it for PWM mode.
Q: Can I use the US-100 with a 3.3V microcontroller?
A: Yes, the US-100 operates at voltages as low as 2.4V, making it compatible with 3.3V systems.