jsheng
Published © GPL3+

Remote Controlled Lights

Lights that turn on when they receive an infrared signal from an old TV remote.

BeginnerShowcase (no instructions)2,491
Remote Controlled Lights

Things used in this project

Hardware components

RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
I used 220 Ohm
×1
IR receiver (generic)
I used 38 kHz TSOP4838
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Breadboard (generic)
Breadboard (generic)
Small ones work well
×1
Old TV Remote
Mine had specific IR codes, you may need to change the codes based on your TV remote. If the infrared signal from your remote is too lengthy, you may need to change the code a little.
×1

Story

Read more

Schematics

IR Light Circuit Diagram

This is a diagram showing how to wire both an RGB LED and a TSOP infrared sensor to an Arduino.

Code

IR RGB Lights

C/C++
Code that basically takes in infrared signals from an old TV remote and deciphers them. A certain infrared signal will change the color of the LED to a certain color. For example, '1' will make the LED red.
#include <IRremote.h>

int numberOfCycles = 10;
int cycleValue = 300;
int RECV_PIN = 2;
int brightness = 0;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value);

    switch (results.value) {
    
    case 2962 : //1
      analogWrite(9, 255);
      analogWrite(10, 0);
      analogWrite(11, 0);
      break;
    case 527250 : //2
      analogWrite(9, 0);
      analogWrite(10, 255);
      analogWrite(11, 0);
      break;
    case 265106 : //3
      analogWrite(9, 0);
      analogWrite(10, 0);
      analogWrite(11, 255);
      break;
    case 789394 : //4
      analogWrite(9, 190);
      analogWrite(10, 255);
      analogWrite(11, 0);
      break;
    case 134034 : //5
      analogWrite(9, 200);
      analogWrite(10, 0);
      analogWrite(11, 255);
      break;
    case 658322 : //6
      analogWrite(9, 0);
      analogWrite(10, 255);
      analogWrite(11, 255);
      break;
    case 21516 : //POWER
      analogWrite(9, 0);
      analogWrite(10, 0);
      analogWrite(11, 0);
      break;
    case 314258 : //PLAY
      for (int i=0 ; i<numberOfCycles ; i++) { 
        cycle();
      }
        
    }
    

    /*if (results.value == 551502015) { 
      brightness = brightness + 10;
    }
    if (results.value == 551534655) { 
      brightness = brightness - 10;
    }*/
    delay (100);
    irrecv.resume(); // Receive the next value
  }
}

void cycle() { 
      analogWrite(9, 255);
      analogWrite(10, 0);
      analogWrite(11, 0);
      delay (cycleValue);
      analogWrite(9, 0);
      analogWrite(10, 255);
      analogWrite(11, 0);
      delay (cycleValue);
      analogWrite(9, 0);
      analogWrite(10, 0);
      analogWrite(11, 255);
      delay (cycleValue);
      analogWrite(9, 190);
      analogWrite(10, 255);
      analogWrite(11, 0);
      delay (cycleValue);
      analogWrite(9, 200);
      analogWrite(10, 0);
      analogWrite(11, 255);
      delay (cycleValue);
      analogWrite(9, 0);
      analogWrite(10, 255);
      analogWrite(11, 255);
      delay (cycleValue);
}

Credits

jsheng

jsheng

0 projects • 11 followers
I am a 12-year-old boy who loves to program software and build hardware. My favorite platforms are Swift 4 and Arduino.

Comments