主程序代码ir_test.ino(IRremote 4.0 + 版本) #include <IRremote.hpp> // include the library const int IR_RECEIVE_PIN = 12; //红外线接收器 接在 pin 12 void setup() { // put your setup code here, to run once: Serial.begin(9600);
#define IR_IN 8 //红外接收 int Pulse_Width=0;//存储脉宽 int ir_code=0x00;//命令值 void timer1_init(void)//定时器初始化函数 { TCCR1A = 0X00; TCCR1B = 0X05;//给定时器时钟源 TCCR1C = 0X00; TCNT1 = 0X00; TIMSK1 = 0X00; //禁止定时器溢出中断 } void remote_deal(void)//...
IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK); // 启动红外解码,并启用LED反馈 } void loop() { if (IrReceiver.decode()) { // 判断是否接收到红外码 Serial.print("bits: "); Serial.println(IrReceiver.decodedIRData.rawDataPtr->rawlen); // 打印红外线码元位数 Serial.print("IRCode: ");...
IR协议简介 IR红外通信是最常用的无线通信方法之一,因为它易于使用且价格合理。波长比可见光长的红外光...
int RECV_PIN = 11; // IR receive pin is 11 IRrecv irrecv(RECV_PIN); long int decodedCode; decode_results rcv; void controlRelays(){ if(decodedCode == 1168) digitalWrite(SW1, LOW); if(decodedCode == 3216) digitalWrite(SW1, HIGH); ...
如果代码中的值等于codeON中的值,则将LED引脚设置为高电平 如果代码中的值等于codeOFF中的值,则将LED 引脚设置为低电平 代码 /*IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecvAn IR detector/demodulator must be connected to the input RECV_PIN.Version 0.1 July, 2009Copyright 2009 Ken...
try to decode it.* Decoded result is in the IrReceiver.decodedIRData structure.*/if (IrReceiver...
显示irCode:FFFFFFFF,bits:32是因为遥控器上没有做中断,误码导致,只要按一下松开,再按一下松开就...
Serial.println("IR decoder"); irrecv.enableIRIn(); // Start the receiver } int on = 0; unsigned long last = millis(); void loop() { if (irrecv.decode(&results)) { // Wait for 0.5sec before decoding another code if (millis() - last > 500) { ...
irrecv.enableIRIn();// Start the receiver pinMode(LED_PIN, OUTPUT); digitalWrite(LED_PIN, HIGH); } voidloop() { if(irrecv.decode(&results)) { Serial.println(results.value, HEX); if(results.value == 0xFFA25D)//开灯的值 { digitalWrite(LED_PIN, LOW); ...