วันอังคารที่ 3 มกราคม พ.ศ. 2560

GP2Y0A02 Infrared Sensor Sharp GP2Y0A02 Distance Sensor 20cm - 150cm

เซนเซอร์วัดระยะทางเป็นเส้นตรงด้วยอินฟาเรด ระยะทางแม่นยำ 20 - 150 เซนติเมตร

รายละเอียด Distance Measuring Sensor 20-150cm (SHARP GP2Y0A02)

Technical / Catalog Information GP2Y0A02
Classification Sensors, Transducers
Analog output type
Range 20cm ~ 150cm
Supply voltage 4.5V ~ 5.5V
Current - 33mA power
Voltage - Output (standard value) @ a distance under the conditions of 400mV @ 150cm
Voltage - difference (standard value) 2.05V @ 20 ~ 150cm
 
ตัวอย่างโคด Arduino Distance Measuring Sensor 20-150cm (SHARP GP2Y0A02)

int IRpin = A0;                               // ต่อเซนเซอร์กับขา A0

void setup() {
   
  Serial.begin(9600);                             
}

void loop() {
  float volts = analogRead(IRpin)*0.0048828125;   // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
  float distance = 65*pow(volts, -1.10);         
  Serial.println(distance);                      
  delay(100);                                     
}



ไม่มีความคิดเห็น:

แสดงความคิดเห็น