Introduction
In this Arduino tutorial, we will learn how to Control LEDs using an IR remote with Arduino This comes under IoT (Internet of Things). In this project, we will control LEDs using an IR Remote. We will be able to turn on LEDs using buttons on the remote.
- IR Remote is used to send IR(Infrared) signals, just like our TV remote.
- LED stands for Light Emitting diode.
Supplies
In order to do this project online, the TinkerCad website can be used, which is beneficial for learning purposes. Whereas for physical projects, the components can be purchased from any electronic store. in both cases, we will require the following components:
Components
- Arduino Uno R3
- IR Remote
- IR Sensor
- 1 small Breadboard
- 1 Breadboard mini
- 4 LEDs of different colors
- 4 resistors (220 ohms)
- Connecting wires
Circuit Diagram
Steps To Control LEDs Using an IR Remote With Arduino
Step 1: Gather all the components on the Digital Board or Physical Table.
IR Sensor:
Step 2: Connect the three terminals of the IR sensor to the BreadBoard Mini.
Step 3: Connect the Power terminal of it to the 5V pin of Arduino.
Step 4: Connect the Ground terminal of it to GND in Arduino at the analog side using a Black colored wire.
Step 5: Connect the out terminal of it to the 2 number pin of the Arduino.
LEDs:
Step 6: Connect all four LEDs to the BreadBoard – Small.
Step 7: Connect the Anode terminals of it to pin numbers 12, 10, 8, and 6, respectively.
Step 8: Connect a resistor to the Cathode terminal of the LEDs and then connect it to the Grounding pin in Arduino using connecting wires.
Source Code
#include <IRremote.h> int ledBlue = 12; int ledRed = 10; int ledGreen = 8; int ledWhite = 6; int IR_Sensor = 2; IRrecv irrecv(IR_Sensor); decode_results result; void setup() { pinMode(ledBlue, OUTPUT); pinMode(ledRed, OUTPUT); pinMode(ledGreen, OUTPUT); pinMode(ledWhite, OUTPUT); Serial.begin(9600); Serial.println("Enabling IRin"); irrecv.enableIRIn(); Serial.println("Enabled IRin"); } void loop() { if (irrecv.decode(&result)) { unsigned int value = result.value; Serial.println(value); switch (value) { case 2295: digitalWrite(ledBlue, HIGH); delay(1000); digitalWrite(ledBlue, LOW); break; case 34935: digitalWrite(ledRed, HIGH); delay(1000); digitalWrite(ledRed, LOW); break; case 18615: digitalWrite(ledGreen, HIGH); delay(1000); digitalWrite(ledGreen, LOW); break; case 10455: digitalWrite(ledWhite, HIGH); delay(1000); digitalWrite(ledWhite, LOW); } irrecv.resume(); } }
Explanation of the Code
Let us understand the code that we have created to Control LEDs using an IR remote with Arduino.
1. In the beginning, we included the header file IRremote.
2. After that, we initialized the LEDs to integer values 12,10,8 and 6, respectively, which denotes the pin number to which they are connected in Arduino Uno. Also, we have declared the IR_Sensor variable to pin number 2.
3. After that, we used the IR library function and variable.
4. Now, after this, we have used two functions, that is, setup and loop.
5. In the setup function, we have declared that we are using LEDs pin numbers for output purposes.
6. The serial.begin() is for enabling serial communication between Arduino and remote.
7. In the loop function, we are using the if statement; if some input is received, it will store its value of it in the value variable.
8. Now, to know which LED we need to glow on which value, we have used a switch case.
9. Inside the switch case, if a particular value is there, we make that LED high for some time and then again make it low.
10. We are doing it using a delay function, which takes time in milliseconds.
11. Atlast, to continue it further, we have used the last function to receive the next value.
Output
We will get the following output on the successful completion of the project Control LEDs Using an IR Remote With Arduino.
Click any of the first four switches;
- On clicking 1 numbered switch, the first LED will glow,
- On clicking switch number 2 from the IR Remote, Red LED turns on.
- On clicking switch number 3, the green LED will glow, and
- On clicking the 4 numbered switch, the white LED will glow.
Thus, using this, we don’t even need to go there to turn on the LEDs.

Cisco Ramon is an American software engineer who has experience in several popular and commercially successful programming languages and development tools. He has been writing content since last 5 years. He is a Senior Manager at Rude Labs Pvt. Ltd.
0 Comments