top of page

ROBOTICS:
PROJECT-BASED LEARNING

PROJECT:
REMOTE LED LIGHTS

Design

Any string of red, green and blue LEDs can serve as the base of your design.

The concept is fairly straightforward, which is to utilise any IR remote such as your TV or fan to transmit and receive information from your circuit in order to control the lights.

​

For simplicity, this circuit here will be built using only a simple LED circuit as the primary purpose is to understand the use of the IR Remote interface

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

WARNING:

It is important to bear in mind that larger lights with longer strings of LEDs  require a higher power source which exceeds the load of the microcontroller

TAKE EXTREME PRECAUTION WHEN USING HIGHER POWER SOURCES!!

DO NOT USE AC POWER (WALL SOCKETS)

What You Need
Microcontroller
LEDs
Resistor
Jumper Wires
Bread
Board
IR 
Receiver
Remote
The Circuit

Created with Fritzing 

The Code

Download and install the IR library from https://github.com/z3t0/Arduino-IRremote

#include <IRremote.h>

 

int RECV_PIN = 8; // the pin where you connect the output pin of the IR receiver

int led1 = 13;

int led2 = 12;

int led3 = 11;

 

int itsONled[] = {0,0,0,0};

 

#define code1  16575 //To obtain these codes open the Serial Monitor and 

#define code2  41055 // copy the code appears whenever a button is 

#define code3  24735  // pressed

 

IRrecv irrecv(RECV_PIN);

 

decode_results results;

​

void setup()

{

  Serial.begin(9600);  

  irrecv.enableIRIn(); 

  pinMode(led1, OUTPUT);

  pinMode(led2, OUTPUT);

  pinMode(led3, OUTPUT);

}

​

​

​

void loop() {

  if (irrecv.decode(&results)) {

    unsigned int value = results.value;

    switch(value) {

       case code1:

         if(itsONled[1] == 1) {       

            digitalWrite(led1, LOW);  

            itsONled[1] = 0;          

         } else {                     

             digitalWrite(led1, HIGH); 

             itsONled[1] = 1;         

         }

          break;

       case code2:

         if(itsONled[2] == 1) {

            digitalWrite(led2, LOW);

            itsONled[2] = 0;

         } else {

             digitalWrite(led2, HIGH);

             itsONled[2] = 1;

         }

   break;

       case code3:

         if(itsONled[3] == 1) {

            digitalWrite(led3, LOW);

            itsONled[3] = 0;

         } else {

             digitalWrite(led3, HIGH);

             itsONled[3] = 1;

         }

          break;         

    }

    Serial.println(value);

    irrecv.resume();

  }

}

TO LEARN MORE,
TAKE OUR ONLINE COURSE

bottom of page