รหัสสินค้า | HC-SR04 |
หมวดหมู่ | Sensor modules |
ราคาปกติ | |
ลดเหลือ | 70.00 บาท |
สถานะสินค้า | พร้อมส่ง |
สภาพ | สินค้าใหม่ |
ลงสินค้า | 30 ส.ค. 2558 |
อัพเดทล่าสุด | 21 พ.ค. 2560 |
จำนวน | ชิ้น |
HC-SR04 Ultrasonic Ranging Sensor Ultrasonic Module For Arduino
Description:
Working Voltage : 5V(DC)
Static Current: Less than 2mA
Output Signal: Electric frequency signal, high level 5V, low level 0V
Sensor Angle: Not more than 15 degrees
Detection Distance: 2cm-450cm
High Precision: Up to 0.3cm
Input Trigger Signal: 10us TTL impulse
Echo Signal : output TTL PWL signal
Quantity: 2
Mode of connection:
VCC
trig(T)
echo(R)
GND
ตัวอย่าง Code
Load library NewPing.h ที่นี่ >> http://www.instructables.com/id/Ultrasonic-Range-detector-using-Arduino-and-the-SR/
// ---------------------------------------------------------------------------
// Example NewPing library sketch that does a ping about 20 times per second.
// ---------------------------------------------------------------------------
#include
#define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup() {
Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}
void loop() {
delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
Serial.print("Ping: ");
Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println("cm");
}
หน้าที่เข้าชม | 273,446 ครั้ง |
ผู้ชมทั้งหมด | 123,965 ครั้ง |
ร้านค้าอัพเดท | 20 ต.ค. 2568 |