我是靠谱客的博主 简单寒风,最近开发中收集的这篇文章主要介绍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控制红外遥控小灯一、实物连接二、程序实现所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部