Infrared Receiver + NEC Coding Remote Control Materials
Infrared Receiver + NEC Coding Remote Control Materials
Overview
In this project we will use an infrared receiver and remote control to turn two LEDs on and off.
Materials
Arduino Uno x 1
Infrared receiver x 1
5mm red LED light x 1
5mm green LED light x 1
NEC remote control x 1
220 Ohm resistor x 2
Breadboard x 1
DuPont wires
Product description
Product Description
The Infrared wireless remote control system consists of the Mini thin infrared remote control and 38KHz
infrared receiver module, The Mini Infrared remote control has 17 function keys and works up to a distance
up to 8 meters. It is ideal for indoor control of various devices. The Infrared receiver module can receive
the standard 38KHz modulation of the remote control signal, and with some programming it can decode the
signal from the remote control and can be used to produce a variety of remote control functions.
Technical Parameters:
Wiring Diagram
Sample code:
#include <IRremote.h>
IRrecv irrecv(RECV_PIN);
decode_results results;
int a=1;
int b=1;
void setup()
{pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
switch(results.value)
{
case 0xFF30CF:digitalWrite(2,a);a=!a;break;
case 0xFF18E7:digitalWrite(3,b);b=!b;break;
}
irrecv.resume(); // Receive the next value
}
}
Results
The project uses button 1 and 2 of remote control to control the red LED and green led to turn on and off.
We will use the red LED in the demonstration (it's the same mechanism with the green LED by pressing key
2)
The red light is off before pressing key 1, as shown below:
The red LED turns on when you press key 1, as shown as below:
The red LED turns off when you press key 1 again.