Arduino 之 红外遥控
1 /* 2 * IRrecvDemo 3 * 红外控制,接收红外命令控制板载LED灯亮灭 4 */ 5 6 #include <IRremote.h> 7 8 int RECV_PIN = 2; 9 int LED_PIN = 13; 10 11 IRrecv irrecv(RECV_PIN); 12 13 decode_results results; 14 15 void setup() 16 { 17 Serial.begin(115200); 18 irrecv.enableIRIn(); // Start the receiver 19 pinMode(LED_PIN, OUTPUT); 20 digitalWrite(LED_PIN, HIGH); 21 } 22 23 void loop() { 24 if (irrecv.decode(&results)) { 25 Serial.println(results.value, HEX); 26 if (results.value == 0x44BB3BC4) //开灯的值 27 { 28 fadeToBlackBy( leds, NUM_LEDS, 10); 29 } else if (results.value == 0x44BB8F70) //关灯的值 30 { 31 digitalWrite(LED_PIN, HIGH); 32 } 33 irrecv.resume(); // Receive the next value 34 } 35 delay(100); 36 }
本文来自博客园,作者:loadbxh,转载请注明原文链接:https://www.cnblogs.com/loadbxh/articles/12034952.html

浙公网安备 33010602011771号