The Ultrsonik Coba Coba is a type of ultrasonic sensor designed for measuring distances by emitting ultrasonic waves and detecting their reflection. It is widely used in applications requiring non-contact distance measurement, such as robotics, obstacle detection, liquid level sensing, and industrial automation. Its ability to provide accurate and reliable measurements makes it a versatile component for various projects.
Pin Name | Pin Number | Description |
---|---|---|
VCC | 1 | Power supply pin. Connect to 5V DC. |
TRIG | 2 | Trigger pin. Send a 10 µs pulse to initiate distance measurement. |
ECHO | 3 | Echo pin. Outputs a pulse width proportional to the measured distance. |
GND | 4 | Ground pin. Connect to the ground of the power supply. |
// Ultrsonik Coba Coba Distance Measurement Example
// This code measures distance using the Ultrsonik Coba Coba sensor and displays
// the result on the Serial Monitor.
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 at 9600 baud
}
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 centimeters
float distance = duration / 58.0;
// 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
}
No Output or Incorrect Readings:
Unstable or Fluctuating Measurements:
Short Measuring Range:
Q1: Can the Ultrsonik Coba Coba measure distances through transparent materials like glass?
A1: No, the sensor may not work reliably through transparent materials as ultrasonic waves may pass through or scatter.
Q2: What is the maximum angle of detection for the sensor?
A2: The sensor has a detection angle of approximately 15 degrees. Ensure objects are within this angle for accurate measurements.
Q3: Can I use the sensor with a 3.3V microcontroller?
A3: The sensor requires a 5V power supply. If using a 3.3V microcontroller, a level shifter is recommended for the TRIG and ECHO pins.