1. Hardwares parts

Receiver

item Quantity
SparkFun RedBoard 1
IR receiver 1
330 Ω\OmegaΩ resistor 1
Jumper 3
Cable 1

Transmitter

item Value
Arduino UNO Board 1
Infrared LED 1
330 Ω\OmegaΩ resistor 1
1 KΩ\OmegaΩ resistor 1
Bottom 1
Jumper 7
Cable 1


— Graphs are created by using Autodesk Tinkercad

Picture:
The red one is receiver. Blue one is transmitter.

2. Softwares Parts

1. Import library --IRremote
2. Receiver code
#include "IRremote.h"int RECV_PIN = 12; //Define Receiver PinNumber 12
int a = 0;
IRrecv irrecv(RECV_PIN); //Create the receiver object
decode_results results; //Define resultsvoid setup()
{Serial.begin(9600);irrecv.enableIRIn();     // Initializes the infrared receiver
}void loop() {if (irrecv.decode(&results)) {// return trueSerial.println(results.value, HEX); // HEX hexadecimal, or base 16irrecv.resume(); // After receiving, this must be called to reset the receiver// and prepare it to receive another code.}delay(110);
}
3. Transmitter code
#include <IRremote.h>                  const int buttonPin = 4; // Define Button PinNumber 4
int buttonState = 0; //Initial states =0
IRsend irsend; //Define infrared void setup()
{pinMode(buttonPin, INPUT); // Setting Button Pin4 = Input
}void loop()
{buttonState = digitalRead(buttonPin);// Read 0 or 1if (buttonState == HIGH) { //if 1 Sending messagesirsend.sendNEC(0x4CB3817E, 32);   // Sending NEC code
}

3. Build a TV controller

Step 1

Upload code into board, open the Serial Monitor.

Step 2

Recording signal from TV controller.

We can see NEC code of the signal for turn on/ turn off is 4AB0F7B6.

Step 3

Open the transmitter code and update signal to 4AB0F7B6. Upload transmitter code to Arduino(transmitter)

Step 4

Testing!!!

4. Questions to Questions

1. What is NEC? How does it work?

The NEC Infrared Transmission Protocol uses pulse distance encoding of the message bits. Each pulse burst (mark – RC transmitter ON) is 562.5µs in length, at a carrier frequency of 38kHz (26.3µs).

Logical bits are transmitted as following:

Logical ‘0’ – a 562.5µs pulse burst followed by a 562.5µs space, with a total transmit time of 1.125ms
Logical ‘1’ – a 562.5µs pulse burst followed by a 1.6875ms space, with a total transmit time of 2.25ms

  • a 9ms leading pulse burst (16 times the pulse burst length used for a logical data bit)
  • a 4.5ms space
  • the 8-bit address for the receiving device
  • the 8-bit logical inverse of the address
  • the 8-bit command
  • the 8-bit logical inverse of the command
  • a final 562.5µs pulse burst to signify the end of message transmission.

2. Why Hex number system in Arduino code?

The NEC system is 32 bits in Binary number systems which can be translated to 8 bits in Hex number system. It is more convenient to read for human.

In C/C++, Hex number must started with 0x

3. Why carrier frequency is 38Hz?

The range of carrier frequency always in 38Hz to 60Hz.
The range is decided by the crystal oscillator at topic. The frequency of crystal oscillator in IR LED is 455Hz. After a frequency divide processing, (455Hz /12 ≈\approx≈ 38Hz) We get a frequency which is 38Hz.

Frequency of Single-Chip Microcomputer . Crystal oscillator is 8

4. Interesting Fings about Why Logical’0’ and Logical’1’ spend 562.5µs and 1.6875ms?

PDM
PDM is a method of reducing the average power delivered by an electrical signal, by effectively chopping it up into discrete parts.

Duty cycle
A duty cycle or power cycle is the fraction of one period in which a signal or system is active.

A nice duty cycle will help with balance between IR led overheating and controlling distance.

The NEC protocol choose 33% as duty cycle rate. (562.5/ 1.6875 = 0.333333…)

Arduino Infrared controller相关推荐

  1. Donkey Car 基于Arduino L298N DIY小车

    Donkey Car 基于 Arduino L298N DIY小车 烧入Arduino程序 测试舵机校准程序 L298N驱动代码修改 L298N接线方式 Donkey Car actuator.py ...

  2. RS485远程无线抄表系统方案及工作原理Wireless Infrared Meter Reading controller

    RS-485远程抄表系统是有线远程抄表系统,这类抄表方式适合于低压集中抄表,一般电表都有RS-485接口,这类抄表方案硬件便宜,适用于小区.写字楼等电表比较集中的地方. 远程抄表分为综合应用层,数据管 ...

  3. arduino 呼吸灯_如何改善您的Arduino呼吸机:用于临时COVID-19呼吸机设计的RTS和SCS简介...

    arduino 呼吸灯 The world as we know it was recently taken by storm. That storm was the outbreak of the ...

  4. ethercard php_使用Arduino和ENC28J60以太网LAN网络模块发送HTTP POST请求

    首先,您需要安装以下库: https://github.com/jcw/ethercard 用6个引脚将模块连接到arduino: > ENC SO – > Arduino引脚12 > ...

  5. arduino编程语言教程_Arduino|编程语言说明

    Arduino在创客领域和简单的工业控制中得到了极为广泛的应用,Arduino使用的ATmega328p芯片,前面我有对ATmega328p芯片的系列教程讲解.今天我们主要看一下在Arduino 这个 ...

  6. Arduino语言介绍

    Arduino语言介绍 Arduino语言是建立在C/C++基础上的,其基础是C语言,Arduino语言只不过把AVR单片机(微控制器)相关的一些参数设置都函数化,不用我们去了解他的底层,让不了解AV ...

  7. 用Arduino远程控制车库门开关

    "我用一个以太网插板负载到Arduino上.如此我便实现了打开我的车库门--就是这样! 我也安装了一个磁传感器,门是开着的或者封闭的都可以让我知道.所有都通过Telnet实现. 我修改了来自 ...

  8. Arduino 各种模块篇 舵机 Modules - Servo

    舵机 舵机是一种非常有意思的,多级齿轮增大扭力的widget.非常有用.在很多方面. Servo is very useful. Now Please check this out : What is ...

  9. Arduino入门(一)

    一.入门语法 Arduino - 板的说明_安科网 Barrel插口是电源(桶插座) 晶振帮助Arduino处理时间问题. Arduino如何计算时间? 答案是,通过使用晶体振荡器. 在Arduino ...

最新文章

  1. Banana PI A20开发板 通过了CE,FCC,RoHS认证
  2. 开源自制6通道航模遥控器,Arduino Pro Mini NRF24L01模块
  3. kickstart命令选项
  4. [转]Zookeeper入门看这篇就够了
  5. H.264/AVC技术进展及其务实发展策略思考
  6. oracle mysql 数据类型对比_Oracle、SQL Server、MySQL数据类型对比
  7. python import os.path_Python常用模块os.path——文件及路径操作
  8. Internet 的50年口述历史七.摩登时代上
  9. One Switch for Mac(系统功能快速切换工具)
  10. 我常用的那些 Git 命令
  11. 错误解决办法:_ZNSaIcED1Ev@@GLIBCXX_3.4
  12. POJ1015 Jury Compromise【背包问题】
  13. Win10 新机,这些必装软件你拥有了吗?
  14. 上拉电阻和下拉电阻的选型和计算
  15. 季节怎么形容_如何形容四季?
  16. 用手机当电脑摄像头的方法
  17. 笔记本系统转移到固态硬盘
  18. bam文件读取_bam格式文件处理大全(一)
  19. 蓝桥--不同非空子串
  20. 博客园自定义背景图片

热门文章

  1. Intelligent Robot
  2. HTML5快速入门(一)—— HTML简介
  3. Do Deep Neural Networks Learn Facial Action Units When Doing Expression Recognition?阅读笔记
  4. dSYM文件解析与分析
  5. Vue引入第三方字体
  6. ORACLE中CLOB介绍及使用
  7. python编程可以用来干嘛,python程序员是干嘛的
  8. h5 生成图片并保存到手机(浏览器)
  9. Eclipse设置编码字体、左侧窗口字体、控制台字体
  10. 克罗地亚3-1战胜苏格兰晋级淘汰赛 当贝投影F3陪你畅爽观赛