Introduction: Control Anything Remotely With Infrared Signals.

About: From solder to zip ties, lead acid batteries and LEDs, and especially Legos, putting things together has always fascinated me. The more challenging the better, because whats the fun of putting something togeth…

Who would have thought that just about every Arduino attachment can be controlled in some way with a TV remote? Now its time to find out how.

Step 1: Setup and Materials

The setup for this is quite basic. The real challenge is finding neat products for this and writing the code.

Materials.
1x Arduino
1x Servo available @ Hobbyking Sparkfun etc.
Jumper wires
1x Infrared receiver diode available @ Sparkfun Allelectronics Radioshack etc.
4x AA Battery and holder Ebay is the cheapest for the holder
1x TV remote

Anything that you want to control

See the attached sketchup for the setup. If you do not have sketchup you can download it here.
http://sketchup.google.com/intl/en/download/

Step 2: Values

The first thing to do is load the below code on to the arduino and open the serial monitor.
Next press a button on the remote aimed at the receiver to see the value printed. Ignore the first value that you see as it may by off.

#include <IRremote.h>

int RECV_PIN = A0; // Analog Pin 0
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

Step 3: Code

Now that you have the values for each button on your remote you can control the servo. Below is also code that you can do without a servo and instead just control the LED on digital pin 13.

You will need to download the infrared library from http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html if you do not have it already.

You may recognize some of this code, and that is to keep everything simple. I am using code widely available on the internet largely from arduino.cc and http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html so that if anyone has questions they can look it up for more reference.

LED code



#include <IRremote.h>

unsigned long someValue = 0xXXXXXXXX; // where XXXXXXXX is on our your remote's values.

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int led = 13;

// the setup routine runs once when you press reset:
void setup() {               

Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);   
}

// the loop routine runs over and over again forever:
void loop() {

if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }

if(results.value == someValue) {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}


}





Servo code



#include <Servo.h>
#include <IRremote.h>

unsigned long Value2 = 0xXXXXXXXX; // where XXXXXXXX is on our your remote's values. We will call this Value 1
unsigned long Value1 = 0xXXXXXXXX; // where XXXXXXXX is another button on your remote

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

Servo servo1;

// the setup routine runs once when you press reset:
void setup() {              

Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  // initialize the digital pin as an output.

servo1.attach(10); // attack servo to digital pin 10
}
}
// the loop routine runs over and over again forever:
void loop() {

if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }

if(results.value == Value1) {
servo1.write(179);
}

if(results.value == Value1) {
servo1.write(1);
}

}

Step 4: Remotely Control Your Life

Everything should be working now. Load the servo code and watch it twist and turn to the values you loaded on the arduino. At this point you could control an entire robot with a TV remote or control appliances. The world is open to being controlled entirely by you with infrared signals.

Please let me know if you have any more ideas or what you have done with infrared signals. Enjoy!

Arduino Challenge

Participated in the
Arduino Challenge

Robot Challenge

Participated in the
Robot Challenge

Make It Real Challenge

Participated in the
Make It Real Challenge

Spy Challenge

Participated in the
Spy Challenge