Introduction: Controlling LED's With an IR Remote
Hi guys, I am Pranjal Verma and this is my tutorial on controlling LEDs with an IR remote. in this tutorial, we will know how to control LEDs on and off with an IR remote and we will be using Arduino Uno R3 for our circuit.
Step 1: Materials : Arduino Uno R3
Arduino Uno R3 is a microcontroller board which would help you to process the codes and makes your circuit work. You can also buy one if you don't have from https://www.amazon.com/Arduino-Uno-R3-Microcontroller-A000066/dp/B008GRTSV6
Step 2: 830 Point Breadboard
Breadboard will help you insert materials for making the circuit. you can also buy one from https://www.amazon.it/Breadboard-contatti-piastra-sperimentale-basetta/dp/B01MQYE3X8
Step 3: Cable for Arduino
This cable will help you to connect your Laptop to the Arduino. you can also buy one from https://robu.in/product/arduino-uno-r3-ch340g-atmega328p-cable-arduino-uno-transparent-acrylic-case-arduino-uno-r3/
Step 4: IR Receiver
IR Receiver will help you to receive IR radiations and send the information to the Arduino. you can buy one from https://www.banggood.com/KY-022-Infrared-IR-Sensor-Receiver-Module-For-Arduino-p-916178.html?rmmds=buy&cur_warehouse=CN
Step 5: IR Remote
IR Remote sends IR Radiations to the IR Receiver. You can also buy one from https://www.amazon.com/DFRobot-DFR0107-Arduino-Compatible-Infrared-Receiver/dp/B00C9NXZZ8
Step 6: Female to Female Jump Wires
Female to Female Jump Wires helps you to connect different materials on the breadboard. You can also buy one from http://projectpoint.in/index.php?route=product/product&product_id=500311102501
Step 7: LED
LED is a light emitting diode which glows when electricity supplied to it. You can also buy it from https://infinity2infinity.in/product/led-pack-basic-ultimatum-200-pieces-5-colours/
Step 8: 220 Resistors
Resistors help to lessen the amount of current flowing in the circuit. You can also buy some from https://www.oddwires.com/25pcs-220-ohm-1-4w-0-25w-1-metal-film-resistor-25-pack/
Step 9: Code of the Tutorial
<p>#include <boarddefs.h><br>#include <IRremote.h> #include <IRremoteInt.h> #include <ir_Lego_PF_BitStreamEncoder.h> int ledb = 13; int ledg = 12; int ledr = 8; int ledy = 7; int ledw = 2; int r = 11; IRrecv irrecv(r); decode_results results; long IRCode = 0;</p><p>void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver pinMode(ledb,OUTPUT); pinMode(ledg,OUTPUT); pinMode(ledr,OUTPUT); pinMode(ledy,OUTPUT); pinMode(ledw,OUTPUT); pinMode(r,INPUT);</p><p>}</p><p>void loop() { if (irrecv.decode(&results)) { Serial.println(results.value); IRCode = results.value; irrecv.resume(); // Receive the next value } if (IRCode == 16724175){ digitalWrite(ledb, !digitalRead(ledb)); } if (IRCode == 16718055){ digitalWrite(ledg, !digitalRead(ledg)); } if (IRCode == 16743045){ digitalWrite(ledr, !digitalRead(ledr)); } if (IRCode == 16716015){ digitalWrite(ledy, !digitalRead(ledy)); } if (IRCode == 16726215){ digitalWrite(ledw, !digitalRead(ledw)); } }</p>
Step 10: How to Create the Circuit
Step 11: Adding More Things to the Circuit
you can add more materials to the circuit by finding the codes of different buttons of the IR Remote and writing the codes for inserting them and write the codes for their working. for example, Below is the code I would be adding to the code I have written to make the LEDs glow in a pattern.
if (IRCode == 16712445){
digitalWrite(ledb,HIGH);
delay(100);
digitalWrite(ledb,LOW);
digitalWrite(ledg,HIGH);
delay(100);
digitalWrite(ledg,LOW);
digitalWrite(ledr,HIGH);
delay(100);
digitalWrite(ledr,LOW);
digitalWrite(ledy,HIGH);
delay(100);
digitalWrite(ledy,LOW);
digitalWrite(ledw,HIGH);
delay(100);
digitalWrite(ledw,LOW); }
Step 12: Solutions If the Circuit Is Not Working
- Check the connections in the circuit if they are correct
- If you don't have an Elegoo IR Remote then find the codes of buttons of your IR Remote and replace your codes with the codes in IRCode == (your code)
- Check that you have copied the code correctly
Step 13: Thank You
please comment for any improvements to the tutorial