Sharp infrared distance sensor เป็นเซนเซอร์วัดระยะที่ใช้หลักการสะท้อนของคลื่นอินฟาเรด
Output เป็นแบบ Analog 0-1023 (0 - 5V)
การต่อวงจร
Arduino | sensor |
5V | VCC (แดง) |
GND | GND (ดำ) |
pin A0 | A0 (เหลือง) |
โค้ดตัวอย่างการใช้งาน
int sensorPin = A0; // select the input pin for sensor
int sensorValue = 0; // variable to store the value coming from the sensor
void setup()
{
Serial.begin(9600);
}
void loop()
{
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
delay(1000);
Serial.print("sensor = " );
Serial.println(sensorValue);
}
ตัวอย่างการประยุกต์ใช้งาน
หน้าที่เข้าชม | 7,125,486 ครั้ง |
ผู้ชมทั้งหมด | 2,822,384 ครั้ง |
เปิดร้าน | 15 ก.ย. 2557 |
ร้านค้าอัพเดท | 6 ก.ย. 2568 |