Sunday, March 1, 2015

Arduino 5-Channel IR Remote Control using RC-5 Remote Control

Control 5 LEDs Connected to Arduino From RC5 IR Remote Control

Control your Arduino from RC-5 remote control

It is good to have an Arduino board and a not expansive remote control like the RC-5 remote control. This remote control is very simple to use in your projects.
This topic shows how to control five LEDs connected to Arduino uno board using rc5 remote control. To know more about the RC5 remote control and how to control the Arduino from this remote visit the following link:

Arduino 5-Channel IR Remote Control using RC-5 Remote Control circuit schematic:

arduino rc5 ir remote control channel arduino code

 The remote control used to control these LEDs is shown below:

rc 5 remote control arduino project

The buttons used to control the five LEDs are as follows:
Button number 1 sends command (01) which controls the first LED,
Button 2 with command (02) controls the second LED, 
Button 3 (command 03) controls the 3rd LED,
Button 4(command 04) controls the 4th LED,
Button 5 (command 05) controls the 5th LED,
The red button has a command of (12), this button turns off all the LEDs at the same time.
The other buttons on the remote control have no effect.
5-Channel IR remote control Arduino code: 
This application is tested and working finely using the following code:
 // Remote controlled five LEDs
 // RC-5 remote control is used
 // Written by: BENCHEROUDA Okba
 unsigned char j, m, address, command=0;
 void setup() {
 pinMode(2, INPUT);
 pinMode(3, OUTPUT);
 pinMode(4, OUTPUT);
 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
 pinMode(7, OUTPUT);
 void loop() {
  //Check if the received signal is RC5 protocol
  for(m = 0; m < 24; m++){
    if(digitalRead(2) != bitRead((m >> 3), 0))
    goto return_;}
   //End checking 
 //Read data
 for(j = 0; j < 11; j++){
 if (j < 5){
  if(digitalRead(2) == LOW){ bitSet(address, 4 - j);}
  else bitClear(address, 4 - j);}
  if(digitalRead(2) == LOW){ bitSet(command, 10 - j);}
  else bitClear(command, 10 - j);}
 delayMicroseconds(1778);        }
 //End read data
 if(address == 0){
   if (command == 1)
   digitalWrite(3, !digitalRead(3));
   if (command == 2)
   digitalWrite(4, !digitalRead(4));
   if (command == 3)
   digitalWrite(5, !digitalRead(5));
   if (command == 4)
   digitalWrite(6, !digitalRead(6));
   if (command == 5)
   digitalWrite(7, !digitalRead(7));
   if (command == 12){
     digitalWrite(3, LOW) ;
     digitalWrite(4, LOW) ;
     digitalWrite(5, LOW) ;
     digitalWrite(6, LOW) ;
     digitalWrite(7, LOW) ; }}


The following video may shows more about this project: