สอน วิธี ใช้งาน Arduino รีโมทอินฟาเรด Infrared Remote Control ใช้ได้ภายใน 3 นาที
ตัวอย่างนี้เป็นการ ใช้งานรีโมทแบบอินฟาเรด กับ Arduino ใช้งานง่าย สามารถนำไปประยุกต์ใช้งานได้อย่างหลากหลาย ดาวน์โหลดไลบารี Arduino Infrared Remote คลิกที่นี่ หลังจากติดตั้งไลบารีแล้ว ทำดังนี้
1. ต่อวงจรตามนี้
2. อัพโหลดโคดตามไฟล์ตัวอย่าง
#include "IRremote.h"
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
3. ตรวจสอบค่าของปุ่มที่กดแล้วส่งไปที่ Arduno ได้จากทาง Serial Monitor