The Omron Ultrasonic Sensor is a device that measures distance by emitting ultrasonic waves and measuring the time it takes for the echo to return. This sensor is widely used in various applications, including robotics, automation, and distance measurement systems. Its ability to provide accurate distance measurements makes it an essential component in many electronic projects.
Parameter | Value |
---|---|
Operating Voltage | 5V DC |
Operating Current | 15mA |
Measuring Range | 2cm to 400cm |
Frequency | 40kHz |
Resolution | 0.3cm |
Angle of Coverage | 15 degrees |
Operating Temperature | -15°C to 70°C |
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (5V DC) |
2 | Trig | Trigger input (initiates the ultrasonic burst) |
3 | Echo | Echo output (receives the reflected signal) |
4 | GND | Ground |
// Define pins for the ultrasonic sensor
const int trigPin = 9;
const int echoPin = 10;
// Define variables for duration and distance
long duration;
int distance;
void setup() {
// Initialize serial communication at 9600 baud rate
Serial.begin(9600);
// Set trigPin as OUTPUT and echoPin as INPUT
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
// Clear the trigPin by setting it LOW
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Set the trigPin HIGH for 10 microseconds to send out the pulse
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the echoPin, which returns the time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculate the distance in cm
distance = duration * 0.034 / 2;
// Print the distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Wait for 100 milliseconds before the next loop
delay(100);
}
No Output or Incorrect Readings:
Fluctuating Readings:
Sensor Not Responding:
By following this documentation, users can effectively integrate the Omron Ultrasonic Sensor into their projects, ensuring accurate and reliable distance measurements.