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

​Arduino Project 049 - IR Remote Control

RonWang5个月前 (12-15)电子编程230

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://www.donstudio.cn/?id=306

标签: Arduino

相关文章

Arduino Project 004 - LED Interactive Traffic Lights

Arduino Project 004 - LED Interactive Traffic Lights

This time you are going to extend the previous project to include a set of pedestrian lights and a p...

Arduino Project 010 - Serial Controlled Mood Lamp

Arduino Project 010 - Serial Controlled Mood Lamp

For Project 10, you will revisit the circuit from Project 8 — RGB Mood Lamp, but you’ll now delve in...

 Arduino Project 043 - SD CardTemperature Datalogger

Arduino Project 043 - SD CardTemperature Datalogger

Todady I made a simple Arduino datalogger using SD card and DHT11  relative humidity and t...

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...

 ​Arduino Project 051 - How to Connect Remote Control

​Arduino Project 051 - How to Connect Remote Control

Project 51 How to Connect Remote Control 4 Channel to Arduino// constants won't c...

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

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

上大学时学习《C语言程序设计》(第二版)作者谭浩强,大部分编程时间是在学校机房度过,每次点开桌面的TurboC图标,就开始在里面敲代码,然后保存程序Abc.C,下一步进行编译,如果编译成功的话,就可以...