Control your computer with a Infrared Remote and Arduino

Hardware related mods, hacks, questions and ideas.
Post Reply
foxmiles
Posts: 90
Joined: Fri Dec 24, 2010 1:57 pm
Contact:

Control your computer with a Infrared Remote and Arduino

Post by foxmiles » Tue Dec 11, 2012 4:49 pm

I've written some code that utilizes Ken Shirriff's IRRemote library for arduino. It emulates an IRMan Infrared Receiver. If you want to try it out you will need:
1. An Arduino
2. IR Reciever something like: http://www.digikey.com/scripts/DKSearch ... 4233661701
NOTE: I haven't tested this receiver yet!
3. IRRemote Library https://github.com/shirriff/Arduino-IRremote
4. EventGhost (windows) http://www.eventghost.org/
or lirc (linux) winlirc (windows) - I haven't messed with these yet.
5. The following code:
Note: I broke my receiver, so I haven't finished testing this code yet! Maybe someone has one and can report back?

Code: Select all

/* Simple irman clone for arduino,
    basically it turns the 8 byte value into the 
    expected 6 bytes and responds OK to the IRMan 
    initialization sequence.

    Definitely not complete
    
    Requires IRremote library from 
    https://github.com/shirriff/Arduino-IRremote
*/

#include <IRremote.h>

int RECV_PIN = 11; // set this to the pin connected to the ir receiver

//int ready = 0;
int i=0;
char temp[10];
char state[8];
int in;

IRrecv irrecv(RECV_PIN);
decode_results results;

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

void loop() {
  initializeIR();
  if (irrecv.decode(&results)) {
    if (results.value != 0xFFFFFFFF) // we ignore the repeat code
    {
      i=0;
      ltoa(results.value, temp, 16);
      while (i<=5)
      {
        state[i] = temp[i+1];
        i++;
      }
      Serial.write(state);
    }
    
    irrecv.resume(); // Receive the next value
  }
}


void initializeIR() // check if trying to initialize
{
   in=Serial.read();
   if (in == 82 || in == 114)
   {
    // ready=1;
     Serial.write("OK"); // O
     in=0;
   }
}
Digging with a spoon will accomplish more than leaning on a shovel.

Jarod
Site Admin
Posts: 189
Joined: Sat Dec 11, 2010 12:34 am
Contact:

Re: Control your computer with a Infrared Remote and Arduino

Post by Jarod » Tue Dec 11, 2012 7:35 pm

The code does indeed work. lirc on the other hand does not... has some odd permissions problems and junk. trying to work that out now.

Video of it all working is rendering and I'll post the link soon

Jarod
Site Admin
Posts: 189
Joined: Sat Dec 11, 2010 12:34 am
Contact:

Re: Control your computer with a Infrared Remote and Arduino

Post by Jarod » Tue Dec 11, 2012 8:35 pm



Tada!

foxmiles
Posts: 90
Joined: Fri Dec 24, 2010 1:57 pm
Contact:

Re: Control your computer with a Infrared Remote and Arduino

Post by foxmiles » Tue Dec 18, 2012 9:22 pm

Found another sensor, it seems to output a lot of garbage along with the codes, (it put out a steady stream of codes, apparently not as good internal filtering as the last one) but it does give me good codes too.

I found a really (kinda) big problem - From the UIR / IRMAN Protocol doc "The device is powered up by setting RTS and DTR high on the host." Unfortunately this is roughly equivalent to holding the reset button down on the Arduino. I didn't catch this at first as the Arduino I was testing on had the auto-reset trace cut for another project.

So I need to either find another protocol or move entirely to writing my own lirc / eventghost plugins. There really can't be much to them. One advantage is that we could would have transmit support easily as well.
Digging with a spoon will accomplish more than leaning on a shovel.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest