[Legacy Content] This page contains very old information, which might not be valid anymore, they are only kept here for legacy purposes.
if you have any inquiries, feel free to contact me! Click here
Created: Tuesday, 01 April 2014 Written by Ehab Eldeeb
There are two types of remote controls:
1- Infra Red (IR)
Range = roughly 9 meters.
It requires a clear line of sight.
2- Radio Frequency (RF)
Range = roughly 30 meters.
It can penetrate walls and go around corners.
In this article, we will explain both of them, but we will be using the IR Remote control in our project.
Most of the devices used at home use IR type of Remote Control.
The remote control contains an internal circuit board, processor, and one or two Light Emitting Diodes (LEDs)
When you push a button on a remote control, it transmits a corresponding code to the receiving device by way of LED infra-red pulses.
The flashing LED light is transmitting a series of 1s and 0s.
The "1" might be represented by a long flash, while "0" is represented by a short flash. A receiver, built into the component, receives the pulses of light and a processor decodes the flashes into the digital bits required to activate the required function.
Remote Control for car doors and remotely controlled toy cars use the RF remote control.
RF remote controls work essentially the same as IR remote controls, except they use radio waves.
As stated, radio waves can also penetrate walls and go around objects and corners, making RF arguably more convenient than IR.
Simply, we will use that IR remote control shown above.
The remote control circuit is already built up; we will only connect the receiver module to Arduino using jumper wires and attach the receiver module on the back of the robot so we can control it as it moves in front of us.
After testing the corresponding output signals of each button, we will write a code that takes actions depending on the data received from such buttons.
[Code will be written in C and will be uploaded to the Arduino Micro-Controller]
The Receiver module shown above takes its input from Infra-Red signals coming from the Remote Control, and it its output signal is digital "pulses".
It's connected with the Arduino Micro-Controller as shown below.
We have two pieces of code, one of them is to "decode" the signals coming from the remote control, and the other one is the actual code that will run and take action depending on the signal received.
Upload this code to Arduino, then point your remote control to the receiver module and press the button that you want to decode its signal.
Copy the output from the "Serial Monitor" in the Arduino application and store it somewhere, we will use it later to take actions based on it.
#define IRpin_PIN PIND
#define IRpin 2
#define MAXPULSE 65000
#define RESOLUTION 20
uint16_t pulses[100][2];
uint8_t currentpulse = 0;
void setup(void) {
Serial.begin(9600);
Serial.println("Ready to decode IR!");
}
void loop(void) {
uint16_t highpulse, lowpulse;
highpulse = lowpulse = 0;
while (IRpin_PIN & (1 << IRpin)) {
highpulse++;
delayMicroseconds(RESOLUTION);
if ((highpulse >= MAXPULSE) && (currentpulse != 0)) {
printpulses();
currentpulse=0;
return;
}
}
pulses[currentpulse][0] = highpulse;
while (! (IRpin_PIN & _BV(IRpin))) {
lowpulse++;
delayMicroseconds(RESOLUTION);
if ((lowpulse >= MAXPULSE) && (currentpulse != 0)) {
printpulses();
currentpulse=0;
return;
}
}
pulses[currentpulse][1] = lowpulse;
currentpulse++;
}
void printpulses(void) {
Serial.println("\r\n int IRsignal[] = {");
for (uint8_t i = 0; i < currentpulse-1; i++) {
Serial.print(pulses[i][1] * RESOLUTION / 10, DEC);
Serial.print(",");
Serial.print(pulses[i+1][0] * RESOLUTION / 10, DEC);
Serial.println(",");
}
Serial.print(pulses[currentpulse-1][1] * RESOLUTION / 10, DEC);
Serial.print(", 0};");
}
Use this code to let the Micro-Controller take actions based on signals coming from the IR Remote Control .. that's your job :)
Here's a sample, I used the buttons Up, Down, Right, Left, Mute, Power.
int UP[] = { 890,436, 60,52, 60,48, 62,160, 62,158, 60,160, 66,44, 62,50, 60,48, 64,158, 62,46, 64,48, 60,50, 62,46, 64,158, 62,158, 62,50, 60,48, 64,46, 62,158, 64,160, 60,158, 62,50, 60,160, 60,160, 64,158, 60,160, 60,160, 62,160, 60,48, 64,46, 62,160, 62,48, 60,50, 62,48, 62,48, 60,52, 60,158, 62,158, 56,56, 60,160, 56,166, 52,166, 54, 0};
int DOWN[] = { 882,446, 52,58, 54,54, 56,166, 54,166, 54,166, 56,56, 60,50, 54,54, 56,166, 54,56, 56,54, 54,56, 54,56, 54,168, 52,166, 54,58, 54,54, 56,56, 52,168, 54,168, 52,168, 52,58, 54,166, 54,166, 56,166, 54,166, 54,166, 56,166, 54,166, 54,58, 52,166, 54,58, 54,54, 56,54, 54,58, 54,54, 56,56, 52,168, 54,56, 52,168, 56,166, 54,166, 54,2268, 882,444, 54, 0};
int RIGHT[] = { 890,438, 60,50, 62,46, 64,158, 62,158, 62,158, 64,48, 60,50, 62,46, 64,158, 62,48, 64