|
|

楼主 |
发表于 2019-7-28 11:22:19
|
显示全部楼层
- /*
- 【Arduino】66种传感器模块系列实验(72)
- 实验七十二:HX1838红外无线遥控套件红外扩展模块(遥控器+接收板)
- 程序之二,1和2键控制板载13脚LED灯的亮暗
- */
- #include <IRremote.h>
- int RECV_PIN = 7;
- int LED_PIN = 13;
- IRrecv irrecv(RECV_PIN);
- decode_results results;
- void setup()
- {
- Serial.begin(9600);
- irrecv.enableIRIn(); // Start the receiver
- pinMode(LED_PIN, OUTPUT);
- digitalWrite(LED_PIN, HIGH);
- }
- void loop() {
- if (irrecv.decode(&results)) {
- Serial.println(results.value, HEX);
- if (results.value == 0xFFA25D) //开灯的值
- {
- digitalWrite(LED_PIN, LOW);
- } else if (results.value == 0xFF629D) //关灯的值
- {
- digitalWrite(LED_PIN, HIGH);
- }
- irrecv.resume(); // Receive the next value
- }
- delay(100);
- }
复制代码 |
|