相关文章推荐
沉稳的生菜  ·  PowerShell脚本运行完 ...·  2 年前    · 
慷慨大方的手术刀  ·  java.io.IOException:无法 ...·  2 年前    · 
威武的汤圆  ·  c++生成dll依赖怎么办-掘金·  3 年前    · 
淡定的猕猴桃  ·  【中金电子与通信】云计算:亚马逊带动北美资本 ...·  3 年前    · 
Code  ›  LED Control IRremote. h v3 - Hackster.io
https://www.hackster.io/Creamms/led-control-irremote-h-v3-5126c5
爱旅游的啤酒
3 年前
Log in Sign up
Projects Projects Channels Channels News Contests Events Videos

Embed the widget on your own site

Add the following snippet to your HTML:

LED Control IRremote. h v3

Control a RGB LED with an IR Remote

Read up about this project on Hackster.io

LED Control IRremote. h v3

Creamms
1 129
  • Overview
  • Things
  • Story
  • Schematics
  • Code
  • Credits
  • Comments (0)
Creamms
Creamms
Published September 25, 2021 © GPL3+

LED Control IRremote. h v3

Control a RGB LED with an IR Remote

Beginner Showcase (no instructions) 129
LED Control IRremote. h v3

Things used in this project

Hardware components

RGB LED
× 1
Arduino UNO
Arduino UNO
× 1
  • Buy from Newark
  • Buy from store.arduino.cc
  • Buy from Adafruit
  • Buy from Arduino Store
  • Buy from CPC
IR remote and receiver
× 1

Story

I couldn't find a super basic program to learn the IRremote v3. All tutorials I found used (receiver.decode(&results)) which is now not used.

Read more

Schematics

remote_controlled_rgb_led_7pDYxdN0IO.fzz

Code

  • Untitled file

Untitled file

Arduino
#include <IRremote.h> // include the IRremote library
#define IR_RECEIVE_PIN 2
long data = 0; 
int redPin = 9; //select the pin for the red LED
int bluePin = 10; // select the pin for the  blue LED
int greenPin = 11; // select the pin for the green LED
void setup() {
  Serial.begin(9600); // begin serial communication with a baud rate of 9600
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
  pinMode(redPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(greenPin, OUTPUT);
void loop() {
  if (IrReceiver.decode()) {
    if (IrReceiver.decodedIRData.decodedRawData != 0) {
      data = IrReceiver.decodedIRData.decodedRawData;
    switch (data) { // compare the value to the following cases
      case 3910598400:
        Serial.println("1, Red");
        setLed(255, 0, 0);
        break ;
      case 3860463360:
        Serial.println("2, Orange");
        setLed(255, 128, 0);
        break ;
      case 4061003520:
        Serial.println("3, Yellow");
        setLed(255, 255, 0);
        break;
      case 4077715200:
        Serial.println("4, Green");
        setLed(0, 255, 0);
        break ;
      case 3877175040:
        Serial.println("5, Blue");
        setLed(0, 0, 255);
        break ;
      case 2707357440:
        Serial.println("6, Intigo");
        setLed(127, 0, 255);
        break ;
      case 4144561920:
        Serial.println("7, Violet");
        setLed(255, 0, 255);
        break ;
    IrReceiver.resume();
void setLed(int r, int g, int b)
 
推荐文章
沉稳的生菜  ·  PowerShell脚本运行完 不要马上关闭用什么命令可以停留窗口窗口_定时任务调用完powershell脚本后自动关闭powershell窗口-CSDN博客
2 年前
慷慨大方的手术刀  ·  java.io.IOException:无法运行程序错误= 2,没有这样的文件或目录_java.io.IOException:无法运行程序"curl":error=2,没有这样的文件或目录_原因: j
2 年前
威武的汤圆  ·  c++生成dll依赖怎么办-掘金
3 年前
淡定的猕猴桃  ·  【中金电子与通信】云计算:亚马逊带动北美资本开支持续回暖,市场份额向头部集中黄乐平 闫慧辰等 乐平科技视角 3天前行业近... - 雪球
3 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号