
เซนเซอร์วัดความเร็วรอบ speed counter สำหรับ Smart Car
เซนเซอร์แสง ให้สัญญาณเอาต์พุตเป็นแบบดิจิตอลค่า 1 เมื่อมีวัตถุผ่านเซนเซอร์พร้อม LED แสดงผล ใช้ไฟเลี้ยง 3.3-5V
ปรับความไวการตรวจจับได้ที่ตัวต้านทานปรับค่าได้บนบอร์ด เหมาะสำหรับนับความเร็วรอบ smart car
ตัวอย่างโคดทดลอง Arduino Speed counter
int sp1 = 2;
int sp2 = 3;
int count_sp1 = 0;
int count_sp2 = 0;
void setup() {
pinMode(sp1, INPUT);
pinMode(sp2, INPUT);
Serial.begin(9600);
}
void loop() {
if (digitalRead(sp1) == 1) {
count_sp1++;
Serial.print("speed1 = "); Serial.println(count_sp1);
}
if (digitalRead(sp2) == 1) {
count_sp2++;
Serial.print("speed2 = "); Serial.println(count_sp2);
}
}




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