这是我们这节课的作业:遥控灯。
红外遥控模块
单词 | word |
---|---|
遥控器 | remote control |
电磁波 | electromagnetic wave |
原理图
代码
#include <IRremote.h>
long ir_item;
IRrecv irrecv_3(3);
decode_results resultes_3;
void setup(){
Serial.begin(9600);
pinMode(4,OUTPUT);
irrecv_3.enableIRIn();
}
void loop(){
if (irrecv_3.decode(&results_3)){
ir_item=results_3.value;
String type="UNKNOWN";
String typelist[14]={"UNKNOWN","NEC","SONY","RC5","RC6","DISH","SHARP","PANASONCI","JVC","SANYO","MITSUBISHI","SANSUNG","LG","WHYNTER",HAIER"};
if(results_3.decode_type>=1&&results_3.decode_type<=13){
type=typelist[results_3.decode_type];
}
Serial.print("IR TYPE:"+type+" ");
Serial.println(ir_item,HEX);
digitalWrite(4,HIGH);
delay(1000);
irrecv_3.resume();
} else {
digitalWrite(4,LOW);
}
}
网友评论