项目创意

利用电视遥控器控制Arduino

字号+ 作者:duino123.com 来源:未知 2016-05-13 17:27 我要评论( )

利用电视遥控器控制Arduino

简介:

One fun way to control an Arduino is with a TV remote. In this project, I am going to show you how you can use any of the buttons on a standard infrared remote control to activate functions on an Arduino. 

材料:

Arduino Microcontroller

38 kHz Infrared Receiver Module

Momentary Switch

100 kohm Resistor

2 x 100 ohm resistor

Green LED

Red LED

Relay (5V 20 mA )

Diode

Breadboard or Printed Circuit Board

Jumper Wires

 

下载安装IRRemote库

This project uses a multi-protocol infrared remote library that was developed by Ken Shirriff. This library allows the Arduino to both decode and transmit the infrared signals that are used in most commercial remote control systems.

You can download a copy of the IRRemote Library by going to his GitHub page and clicking the “Download ZIP” button on the right side of the page.

Next extract all the files. Move the "IRRemote" folder that has been extracted to your Arduino libraries directory. In the most recent versions of the Arduino software, there is another folder already in the library directory called “RobotIRremote.” This has a subfolder in it that is also named “IRRemote.” If both folders are in the library, the Arduino won’t know which one to reference and it will generate an error. The easiest way to resolve this problem is to simply delete the RobotIRremote folder. If you don’t want to delete it, you can go into the subfolders and rename all the folders that cause conflicts.

 

连接红外接收器:

The infrared receiver module has three pins. As illustrated in the picture below, the right pin connects to 5V. The center pin connects to GND. The left pin is the output pin and connects to one of the digital pin on the Aduino set to input mode. This pin configuration may be different depending on the manufacturer of your part. So always consult the manufacturers datasheet before hooking it up. This in the only part that you need in order to receiver infrared signals with your Arduino. Once you have made these connections, you are ready to set up code. 

 

源代码:

Using this code, the Arduino will constantly monitor the output of the IR receiver module. When it detects a signal from a remote, it decodes the signal and converts it into a numerical value. This value is stored in a variable and can be used to activate any functions that you wish to add into the code. Using the Serial Monitor tool, you can see the number values that are generated by each button on your remote. Once you know the values, all you have to do is add them into your code and set up conditional statements that will perform the desired action whenever this button is pressed on the remote. When writing the code, keep in mind that a lot of remotes will send the same code multiple times or a series of codes every time you press a button. 

如需更详细资料,如有好资源分享,请加入QQ交流群:214461008

欢迎阅读,欢迎转载,不用注明出处!本站只提供入门和进阶资料,做您学习的小伙伴!

老司机也欢迎光临指导!有好内容请加群:214461008 不要看声明了,看内容吧!

相关文章
  • 利用8266与物联网平台监控温度湿度

    利用8266与物联网平台监控温度湿度

    2016-04-28 18:03

  • 利用arduino自制钢琴小键盘+播放内置曲子

    利用arduino自制钢琴小键盘+播放内置曲子

    2016-04-17 15:56

  • 利用arduino检测闪电  错过今年夏天就要等明年了

    利用arduino检测闪电 错过今年夏天就要等明年了

    2016-04-17 14:11

网友点评
Arduino