Controlling LED on Arduino using IR Remote

Do you know how infrared receiver works and how to use it?


Infrared receiver, or IR receiver, is a device that receives and decodes infrared signal. When an infrared remote control is used on the IR receiver, the device will translate the signal and then transmit the information to other devices. 


This video will show you how to control LEDs using IR remote on Arduino.

Hardware Preparation

This is the hardware connection and the components needed.

Photo 2019 08 23 08 59 36
Figure 1 : IR receiver connection
Photo 2019 08 23 08 59 24
Figure 2 : Hardware connection

Sample Code

// Include IR Remote Library by Ken Shirriff
#include <IRremote.h>
// Define sensor pin
const int RECV_PIN = 4;
// Define LED pin
#define RED 8
#define GREEN 9
#define YELLOW 10
#define BLUE 11
// Define integer to remember toggle state
int redState = 0;
int greenState = 0;
int yellowState = 0;
int blueState = 0;
// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
// Enable the IR Receiver
// Set LED pins as Outputs
pinMode(RED, OUTPUT);
pinMode(BLUE, OUTPUT);
void loop() {
if (irrecv.decode(&results)) {
switch (results.value) {
case 0xCD3221DE:
if (redState == 0) {
digitalWrite(RED, HIGH);
redState = 1;
else {
digitalWrite(RED, LOW);
redState = 0;
case 0xCD32916E:
if (greenState == 0) {
digitalWrite(GREEN, HIGH);
greenState = 1;
else {
digitalWrite(GREEN, LOW);
greenState = 0;
case 0xCD329B64:
if (yellowState == 0) {
digitalWrite(YELLOW, HIGH);
yellowState = 1;
else {
digitalWrite(YELLOW, LOW);
yellowState = 0;
case 0xCD326996:
if (blueState == 0) {
digitalWrite(BLUE, HIGH);
blueState = 1;
else {
digitalWrite(BLUE, LOW);
blueState = 0;
view raw IRremote.ino hosted with ❤ by GitHub

References :

  1. Using IR Remote Controls with Arduino

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiry, please post at Cytron Technical Forum.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

DIY Digital Alarm Clock Using REKA:BIT With Micro:bit
Display Internet Time (NTP) on micro:bit
DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
Tutorials of Cytron Technologies Scroll to Top