#include <IRremote.h>
int RECV_PIN = 13;
int green=8;
int yellow=7;
int red=6;
boolean ledState = LOW;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(red,OUTPUT);
pinMode(yellow,OUTPUT);
pinMode(green,OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
if(results.value == 0xFFA25D){
ledState = !ledState;
digitalWrite(red,ledState);
digitalWrite(yellow,ledState);
digitalWrite(green,ledState);
}
else if(results.value==0xFF30CF){
digitalWrite(green,HIGH);
digitalWrite(yellow,LOW);
digitalWrite(red,LOW);
}
else if(results.value==0xFF18E7){
digitalWrite(red,HIGH);
digitalWrite(green,LOW);
digitalWrite(yellow,LOW);
}
else if(results.value==0xFF7A85){
digitalWrite(yellow,HIGH);
digitalWrite(green,LOW);
digitalWrite(red,LOW);
}
irrecv.resume();
}
}
红外
最新推荐文章于 2024-01-06 23:16:40 发布