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

Arduino Project 050 - IR Remote Control Light

RonWang2周前 (12-16)电子编程47


Project 50 IR Remote Control Light

50 IR Remote Control Light Circuit

50 IR Remote Control Light Schematic

/* Project 50 IR Remote Control Light
 * 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
int RedPin = 2;
int BluePin = 3;
int YellowPin = 4;
DIYables_IRcontroller_17 irController(IR_RECEIVER_PIN, 200); // debounce time is 200ms
void setup() {
  Serial.begin(9600);
  irController.begin();
  pinMode(RedPin, OUTPUT);      // sets the digital pin as output
  pinMode(BluePin, OUTPUT);      // sets the digital pin as output
  pinMode(YellowPin, OUTPUT);      // sets the digital pin as output
}
void loop() {
  Key17 key = irController.getKey();
  if (key != Key17::NONE) {
    switch (key) {
      case Key17::KEY_1:
       Serial.println("1");
       digitalWrite(RedPin, HIGH);
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_2:
        Serial.println("2");
        digitalWrite(BluePin, HIGH);
        // TODO: YOUR CONTROL
        break;
      case Key17::KEY_3:
        Serial.println("3");
        digitalWrite(YellowPin, HIGH);
        // 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");
        digitalWrite(RedPin, LOW);
        digitalWrite(BluePin, LOW);
        digitalWrite(YellowPin, LOW);
        // 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=307

标签: Arduino

相关文章

Books Exploring Arduino

Books Exploring Arduino

Exploring Arduino uses the popular Arduino microcontroller platform as an instrument to teach topics...

Arduino Project 015 - Simple Motor Control

Arduino Project 015 - Simple Motor Control

First, you’re going to simply control the speed of a DC motor in one direction, using a power transi...

Arduino Programming Basic - Serial Monitor

Arduino Programming Basic - Serial Monitor

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

Arduino Project 023B - Liquid Crystal Displays -Blink and Cursor

Arduino Project 023B - Liquid Crystal Displays -Blink and Cursor

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

Arduino Project 023D - Liquid Crystal Displays - Custom Character

Arduino Project 023D - Liquid Crystal Displays - Custom Character

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

发表评论

访客

看不清,换一张

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