遥控灯

作者: mouse0531 | 来源:发表于2020-01-10 22:07 被阅读0次

这是我们这节课的作业:遥控灯。


红外遥控模块
单词 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);
  }
}

谢谢观看~~~

相关文章

网友评论

    本文标题:遥控灯

    本文链接:https://www.haomeiwen.com/subject/sgbmactx.html