6红外遥控程序

#include <IRremote.h>
int RECV_PIN = 11;
int LED_PIN = 2;
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);
}

红外接收器

猜你喜欢

转载自www.cnblogs.com/Sonny-xby/p/11083480.html