• Ankita Sharma

Controlling LEDs using IR Remote and Arduino UNO on TinkerCAD

Simulation software allows us to make digital prototypes of electronic circuits to avoid wastage and damage to hardware components. It provides a cost-effective way to analyze the behavior and outcomes of the circuits. TinkerCAD is one of the most popular and easy to use and free simulation software. Learn how to make TinkerCAD circuit prototypes in this section.


With evolving technologies, many automation technologies have come up. Earlier LEDs and bulbs were limited to switches, but now you can control your devices while sitting in bed with remotes or your android phones. In this article, we will learn to control LEDs using IR Remote and Arduino on TinkerCAD software.


Software Requirements :


TinkerCAD :

TinkerCAD Software

TinkerCAD is a free #software that runs on a web browser to create 3D models and electronic circuit prototypes. It was developed by Autodesk and launched in the year 2011. Due to its simplicity, it has become a very popular platform for creating digital prototypes.


Visit the TinkerCad website and design your own circuit.


Components Required :


The following components need to be selected from the component list in the TinkerCAD circuit simulation -

All Components

Arduino UNO :

Arduino UNO

Arduino #UNO is an open-source microcontroller board containing a set of digital, analog pins, power pins, and interfaces for serial communication and USB (Universal Serial Bus) ports. Arduino boards are used to read inputs like light on a sensor and turn it into an output.


Buy Arduino UNO from here.


Breadboard :

Breadboard

They are basically a construction base used for prototyping electronic circuits. Breadboards allow us to make quick connections between hardware components, without soldering.


Buy Breadboard from here.


IR Remote :

IR Remote

IR (InfraRed) remotes are a handheld wireless device to operate other electronic devices. #IR remotes act as a transmitter that carries signals from remote to the devices it controls. It emits lights in an infrared range that corresponds to specific commands, such as power on, volume up, etc. The controlled device acts as a receiver. It decodes the infrared pulses of light and executes the command.


IR Sensors :

IR Sensors

IR ( InfraRed ) Sensors refers to an electronic device that measures and detects Infrared Radiations.


Buy the IR Sensor module from here.


LEDs :

LEDs

#LEDs ( Light Emitting Diodes ) are semiconductor devices that emit light whenever current flows through them. It consists of two leads - Cathode and Anode. Cathode lead is smaller as compared to the anode.


Buy LEDs from here.


Resistors :

Resistor

#Resistors are passive two-terminal devices used to limit the amount of current flow in the circuit. They protect the sensor from the high electricity flow. For this design, we will be using 3 resistors each of resistance 220-ohm.


Buy Resistance box from here.


Note: We don't need any physical components to make this project. The circuit simulation is done using TinkerCAD circuit design software.


Circuit Connections :


The circuit connections for this design are as follows -

Circuit Connections
  1. Anodes of the #LEDs are connected to pin 2, pin3, and pin4 of the Arduino UNO board respectively.

  2. Cathodes of the LEDs are connected to a 220-ohm resistor which is further connected to the ground of the breadboard.

  3. GND of the IR sensor ( middle terminal ) is connected to the ground of #Arduino UNO.

  4. The power ( third terminal) of the IR #Sensor is connected to the positive power supply ( +5V ) of the Arduino UNO board.

  5. The output ( first terminal ) of the IR Sensor is connected to Pin12 of the Arduino board.

  6. GND pin of the Arduino board is connected to the GND of the breadboard.


Code Explanation :


The code explanation is as follows -

 #include <IRremote.h>

Including the IRremote library which will help to send and receive #infrared signals.


int IR_Recv = 12;   
int bluePin = 2;
int orangePin = 3;
int greenPin = 4;

In the above command lines, we have defined variables for IR Sensors, BlueLEDs, OrangeLEDs, and green LEDs, and then assigned pins to them.

IRrecv irrecv(IR_Recv);

The above command line enables us to receive Infrared Signals from the IR sensor.

decode_results results;

The above command line allows us to decode the input received. Now, going inside the setup function.

void setup(){
  Serial.begin(9600);  

This command enables serial communication and displays messages on the screen.

irrecv.enableIRIn();

The above command allows the IR Sensor to receive input from the IR #Remote

  pinMode(2, OUTPUT);      // sets the digital pin as output
  pinMode(3, OUTPUT);      // sets the digital pin as output
  pinMode(4, OUTPUT);      // sets the digital pin as output  
}

The above command lines are used to set digital pins named 2,3 and 4 as OUTPUT pins.

void loop(){
  //decodes the infrared input
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    Serial.println(results.value);

If the IR Sensor can decode the input signal, we enter into the switch case statement to control the LED's using IR Remote.

 switch (results.value){
      case 16582903: //when you press the 1 button
        digitalWrite(2, HIGH);
        break;    
      case 16615543: //when you press the 2 button
        digitalWrite(2, LOW);    
        break;

Press button 1 of the IR Remote to switch ON the Blue LED, while Press 2 to switch OFF the LED.

 case 16599223: //when you press the 3 button
        digitalWrite(3, HIGH);
        break;            
       case 16591063: //when you press the 4 button
        digitalWrite(3, LOW);
        break;  

Orange LED can be controlled by using buttons 3 ( ON ) and 4 ( OFF ).

       case 16623703 : //when you press the 5 button
        digitalWrite(4, HIGH);
        break;        
       case 16607383: //when you press the 6 button
        digitalWrite(4, LOW);
        break;

Similarly, Green LED can be controlled using buttons 5 ( ON ) and 6 ( OFF ) respectively.

    }
    irrecv.resume(); 
  }
  delay(10);
}

The above command line is used to receive the next input from the button you press.


Complete Code :


 #include <IRremote.h>

int IR_Recv = 12;   //IR Receiver Pin 3
int bluePin = 2;
int orangePin = 3;
int greenPin = 4;

IRrecv irrecv(IR_Recv);
decode_results results;

void setup(){
  Serial.begin(9600);  //starts serial communication
  irrecv.enableIRIn(); // Starts the receiver
  pinMode(2, OUTPUT);      // sets the digital pin as output
  pinMode(3, OUTPUT);      // sets the digital pin as output
  pinMode(4, OUTPUT);      // sets the digital pin as output  



}

void loop(){
  //decodes the infrared input
  if (irrecv.decode(&results)){
    long int decCode = results.value;
    Serial.println(results.value);
    //switch case to use the selected remote control button
    switch (results.value){
      case 16582903: //when you press the 1 button
        digitalWrite(2, HIGH);
        break;    
      case 16615543: //when you press the 2 button
        digitalWrite(2, LOW);    
        break;
       case 16599223: //when you press the 3 button
        digitalWrite(3, HIGH);
        break;            
       case 16591063: //when you press the 4 button
        digitalWrite(3, LOW);
        break;        
       case 16623703 : //when you press the 5 button
        digitalWrite(4, HIGH);
        break;        
       case 16607383: //when you press the 6 button
        digitalWrite(4, LOW);
        break;
    }
    irrecv.resume(); // Receives the next value from the button you press
  }
  delay(10);
}

Download the document given below, copy the code, and then paste it into the TinkerCAD code section.

Code
.docx
Download DOCX • 13KB


Working :


Once the connections are established and code is written in the code section of TinkerCAD, simulate the circuit design. Now, you are all set to control your LEDs using IR Remote.

Controlling LEDs using IR Remote

IR Remote emits lights in an infrared range that corresponds to specific commands ( power ON / OFF ) while the IR Sensor acts as a receiver that detects and decodes the infrared pulses of light then executes the command.


Blue LED can be controlled by clicking button 1 ( ON ) and button 2 (OFF ) of the IR Remote. Orange LED can be controlled with the help of Button 3 ( ON ) and Button 4 ( OFF ). Similarly, you can control Green LED using Button 5 ( ON ) and Button 6 ( OFF ) respectively.


Check out the video given below to get a better idea through practical implementation.


Video By - Sri Harshita


Conclusion :


#TinkerCAD is a cost-effective way to analyze the output of the circuit before it is actually implemented. It allows us to create digital prototypes to avoid damage to electric components. For more projects through TinkerCad click here.


Controlling LEDs using IR remotes is the most basic home automation technology used nowadays. You can also control other devices such as fans, bulbs, etc using IR remotes.

See also:


  • Facebook
  • YouTube
  • Instagram
  • LinkedIn
LearnElectronics
Contact Us
© Copyright - LearnElectronics 2020.