9905| 9
|
[入门] 【Aruduino】红外遥控 |
本帖最后由 iooops 于 2017-2-28 20:09 编辑 楼主前一阵搬家了 = = 然后壁灯开关太让人心酸 = = 于是打算用遥控加舵机来控制壁灯的开关。 ================================================================================= 下面是楼主对红外遥控部分的学习: 楼主买的套件是淘宝货 = = 然后很坑爹地因为接线的问题纠结了许久 = = 厂家都木有标VCC,GND,D楼主表示蛋疼 = = 就是下面这货,Keyes的 = =。 (G) Ground = Black, (V) Voltage = Red, (S) Signal = White 然后它的配套遥控器是这样的,里面要加一节纽扣电池: 貌似用其他遥控器也可以 = =。 Arduino读数据的代码如下,记得下载安装IRRemote库先:https://github.com/z3t0/Arduino-IRremote Signal接Arduino 11号引脚 [mw_shl_code=cpp,true]/* * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv * An IR detector/demodulator must be connected to the input RECV_PIN. * Version 0.1 July, 2009 * Copyright 2009 Ken Shirriff * http://arcfn.com */ #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 } delay(100); } [/mw_shl_code] 下面是键值表: 先写这么点,回头再补几刀………… 参考: https://arduino-info.wikispaces.com/IR-RemoteControl http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-xinda-keyes-infrared-remote-tutorial/#Xinda_Keyes_Infrared_Receiver_Pin-outs |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed