当前位置:首页 > 科学研究 > 电子编程 > 正文内容

​Arduino Project 049 - IR Remote Control

RonWang2个月前 (12-15)电子编程105

Project 49 IR Remote Control


49 Basic IR Remote Control Circuit

49 Basic IR Remote Control Schematic

/* Project 49 IR Remote Control
 * Coding by Ronwang 
 * This example code is in the public domain
 * Hardware Support by Autaba Website :https://www.autabaec.com
 */
#include <DIYables_IRcontroller.h> // Added DIYables_IRcontroller library
#define IR_RECEIVER_PIN 8 // The Arduino pin connected to IR controller
DIYables_IRcontroller_17 irController(IR_RECEIVER_PIN, 200); // debounce time is 200ms
void setup() {
  Serial.begin(9600);
  irController.begin();
}
void loop() {
  Key17 key = irController.getKey();
  if (key != Key17::NONE) {
    switch (key) {
      case Key17::KEY_1:
        Serial.println("1");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_2:
        Serial.println("2");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_3:
        Serial.println("3");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_4:
        Serial.println("4");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_5:
        Serial.println("5");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_6:
        Serial.println("6");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_7:
        Serial.println("7");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_8:
        Serial.println("8");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_9:
        Serial.println("9");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_STAR:
        Serial.println("*");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_0:
        Serial.println("0");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_SHARP:
        Serial.println("#");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_UP:
        Serial.println("UP");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_DOWN:
        Serial.println("DOWN");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_LEFT:
        Serial.println("LEFT");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_RIGHT:
        Serial.println("RIGHT");
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_OK :
        Serial.println("OK");
        // TODO: YOUR CONTROL
        break;
      default:
        Serial.println("WARNING: undefined key:");
        break;
    }
  }
}


版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://parentscn.com/?id=306

标签: Arduino

相关文章

 Arduino Project 038 - Simple Ultrasonic Range HC-SR04

Arduino Project 038 - Simple Ultrasonic Range HC-SR04

Ultrasonic range finders measure distance by emitting a pulse of ultrasonic sound that travels throu...

C语言调试运行环境Pelles C的安装

C语言调试运行环境Pelles C的安装

C语言调试运行环境之TurboC一文介绍了在32位Windows系统下安装C语言运行环境之TubroC,但是由于TurobC只能在32位系统下运行,导致现在很多Windows10和Windows 11...

Arduino Project 023 - Liquid Crystal Displays - Hello World

Arduino Project 023 - Liquid Crystal Displays - Hello World

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14...

Arduino Project 016 - L293D Motor Driver IC

Arduino Project 016 - L293D Motor Driver IC

In the previous project, you used a transistor to control the motor. In this project, you are going...

Arduino Programming Basic - Funcation

Arduino Programming Basic - Funcation

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静...

Arduino Project 006 - LED Interactive Chase Effect

Arduino Project 006 - LED Interactive Chase Effect

Leave your circuit board intact from Project 5. You’re just going to add a potentiometer to this cir...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。