我是靠谱客的博主 简单寒风,这篇文章主要介绍arduino控制红外遥控小灯一、实物连接二、程序实现,现在分享给大家,希望可以做个参考。

一、实物连接

在这里插入图片描述

二、程序实现

代码如下:


#include <IRremote.h>
const int irReceiverPin =12; 
const int ledPin = 13;
IRrecv irrecv(irReceiverPin); 
decode_results results;

//Servo my_duoji1;
//Servo my_duoji2;

void setup()
{
  pinMode(ledPin,OUTPUT);//set ledpin as OUTPUT
  Serial.begin(9600);//initialize serial 
  irrecv.enableIRIn(); //enable ir receiver module 
}
void loop() 
{
  if (irrecv.decode(&results)) 
  { 
    Serial.print("irCode: "); //print"irCode: " 
    Serial.print(results.value, HEX); //print the value in hexdecimal 
    Serial.print(", bits: "); //print" , bits: " 
    Serial.println(results.bits); //print the bits
    irrecv.resume(); // Receive the next value 
  } 
  delay(600); //delay 600ms
  if(results.value == 0xFFA25D)//if receiver module receive OxFFA25D
  {
     digitalWrite(ledPin,HIGH);
  }
  else
  {
    digitalWrite(ledPin,LOW);//turn off the led
  }
}

最后

以上就是简单寒风最近收集整理的关于arduino控制红外遥控小灯一、实物连接二、程序实现的全部内容,更多相关arduino控制红外遥控小灯一、实物连接二、程序实现内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部