• ตอบกระทู้
  • ตั้งกระทู้ใหม่
QUOTE 

เกิด error จากโค้ดของตัว Infrared sensor sharpGP2Y0A02 อะครับช่วยดุหน่อยครับ

safehoho02
#include <SharpIR.h>

#define ir A0
#define model 20150
// ir: the pin where your sensor is attached
// model: an int that determines your sensor: 1080 for GP2Y0A21Y
// 20150 for GP2Y0A02Y
// (working distance range according to the datasheets)
// updated by Ahmad Nejrabi from Robojax.com
// get latest datasheets: http://www.sharp-world.com/products/device/lineup/selection/opto/haca/diagram.html
// model: an int that determines your sensor:
/*
* GP2Y0A02YK0F --> "20150"
GP2Y0A21YK --> "1080"
GP2Y0A710K0F --> "100500"
GP2YA41SK0F --> "430"
*/

SharpIR SharpIR(ir, model);

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
delay(2000);

unsigned long startTime=millis(); // takes the time before the loop on the library begins

int dis=SharpIR.distance(); // this returns the distance to the object you're measuring


Serial.print("Mean distance: "); // returns it to the serial monitor
Serial.println(dis);

unsigned long calcTime=millis()-startTime; // the following gives you the time taken to get the measurement
Serial.print("Time taken (ms): ");
Serial.println(calcTime);

}

เกิด ERROR ด้านล่างนี้ครับ
C:\Users\hp\AppData\Local\Temp\Rar$DIa11192.38298\SharpSensorCm\SharpSensorCm.ino: In function 'void loop()':
SharpSensorCm:31:19: error: 'class SharpIR' has no member named 'distance'; did you mean 'getDistance'?
int dis=SharpIR.distance(); // this returns the distance to the object you're measuring
^~~~~~~~
getDistance
Multiple libraries were found for "SharpIR.h"
Used: C:\Users\hp\OneDrive\เอกสาร\Arduino\libraries\SharpIR
Not used: C:\Users\hp\OneDrive\เอกสาร\Arduino\libraries\SharpIR-master
Using library SharpIR at version 2.0.1 in folder: C:\Users\hp\OneDrive\เอกสาร\Arduino\libraries\SharpIR
exit status 1
'class SharpIR' has no member named 'distance'; did you mean 'getDistance'?
QUOTE 
ความคิดเห็นที่ #1
เจ้าของร้าน

เท่าที่ดูคิดว่าน่าจะเป็นที่ Library ครับ อาจจะไม่ตรงกับ code ครับ  

แสดงความคิดเห็นที่ 1-1 จากทั้งหมด 1 ความคิดเห็น
WEBBOARD-LOGIN-BEFORE-TOPIC-REPLY

Join เป็นสมาชิกร้านค้า

ร้านAB-Maker บทความ Arduino จำหน่าย Sensor Module Shield ราคาถูก AB.in.th
ร้านAB-Maker บทความ Arduino จำหน่าย Sensor Module Shield ราคาถูก AB.in.th
/www.ab.in.th/
Join เป็นสมาชิกร้าน
529
สมัครสมาชิกร้านนี้ เพื่อรับสิทธิพิเศษ

ติดต่อร้าน AB-Maker

075-808-080
064-208-3926

ติดต่อเวลา 10.00-17.00 น. 
จันทร์ ถึงวัน ศุกร์ 

Fanpage AB-Maker Arduino Line @AB-Maker Arduino

QR Coard Line

  • ค้นหา
*ใส่ เบอร์มือถือ หรือ email ที่ใช้ในการสั่งซื้อ

หน้าที่เข้าชม4,510,768 ครั้ง
ผู้ชมทั้งหมด2,466,540 ครั้ง
ร้านค้าอัพเดท6 ก.ย. 2568
รายการสั่งซื้อของฉัน
เข้าสู่ระบบด้วย
เข้าสู่ระบบ
สมัครสมาชิก

ยังไม่มีบัญชีเทพ สร้างบัญชีใหม่ ไม่มีค่าใช้จ่าย
สมัครสมาชิก (ฟรี)
รายการสั่งซื้อของฉัน
ข้อมูลร้านค้านี้
ร้านAB-Maker บทความ Arduino จำหน่าย Sensor Module Shield ราคาถูก AB.in.th
AB-Maker บทความ Arduino จำหน่าย Sensor Module Shield ราคาถูก AB.in.th
Arduino นครศรีธรรมราช หาดใหญ่ สงขลา ยะลา จำหน่าย Arduino อุปกรณ์อิเล็กทรอนิกส์ ไมโครคอนโทรลเลอร์ Uno R3 Nodemcu Esp8266 Esp32 Sensor Module ราคาถูกสุดๆ Support เร็วดูแลลูกค้าอย่างดี
เบอร์โทร : 075808080
อีเมล : [email protected]
ส่งข้อความติดต่อร้าน
เกี่ยวกับร้านค้านี้
สินค้าที่ดูล่าสุด
ดูสินค้าทั้งหมดในร้าน
สินค้าที่ดูล่าสุด
บันทึกเป็นร้านโปรด
Join เป็นสมาชิกร้าน
แชร์หน้านี้
แชร์หน้านี้

TOP เลื่อนขึ้นบนสุด
พูดคุย-สอบถาม