Click These:

Friday, December 23, 2011

Universal IR Remote + Arduino: Obtaining IR Receiver Codes

I recently thought it would be cool to take a universal remote control made for a tv/dvd/vcr/etc... and turn it into a midi controller for my computer, using an arduino, the aforementioned universal remote control, and an infrared receiver. 


all you need to do to set it up is get an infrared receiver and connect the infrared receivers pins to the arduino. put pin 1 (the ir receivers output) to digital input 11, connect pin 2 into to ground, and connect pin 3 to 5 volt current on the arduino.


Next you are going to need to find a TV remote, or DVD remote, a universal remote, or some kind of remote... any kind will work. 


Once you've found one, you should download and install the IRremote library to your arduino's libraries folder. here is a link to download the zip folder of the IRremote library




http://www.arcfn.com/2010/01/using-arbitrary-remotes-with-arduino.html




and here is a link to the blog of the person who created that library for arduino.
http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html


anyway,you just download the zip file and unpack it to the arduino/hardware/libraries folder... 


once you have it installed and see it in the arduino programs libaries directory, you are ready to use the library in your code.

first off, you'll want to open up the example .pde file called IRrecvDemo

once you have this open, it should look like this.

---------------------------------------------------------------------------------------

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */


#include <IRremote.h>


int RECV_PIN = 11;


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
  }
}


--------------------------------------------------------------------------------------------


upload the IRrecvDemo code to your arduino board, and open the serial monitor once its done uploading...
with the serial monitor open, and the IR receiver connected to the arduino... you should be able to get the IR signal codes from the remote control now... point your remote at the IR receiver, and push some buttons... You should start to see different numbers appear in the serial monitor.



you can write these numbers down, and create code for your arduino that will enable you to make it do something when it detects you've pressed a button on the remote. you can code the arduino to do anything you want... You can make it so that when you push a button, a motor turns on/speeds up/slows down, or make something turn on and off, or control a machine or robot, or send commands to your computer, or whatever else you can imagine it doing... you can pretty much program the remote to do any damn thing you can imagine...

i imagined using it as a MIDI controller to use with my audio programs on my computer...  so thats what i'm doing. so far, i've programmed only 1 button on the controller to send a MIDI signal... the power button. I will eventually write code that turns the whole remote into a very versatile music controller.


1 comment: