# Sending IR signals to Robosapien using Arduino

I am trying to send commands to a Robosapien (first generation) using an IR LED hooked up to an Arduino. I have seen web pages on attaching a microcontroller directly to the toy, but what I want to do is just send commands via IR.

I found an article by K. Smith that mentioned that the IR commands sent by the Robosapien remote take the following form:

To send the hex code 85:

The IRout signal is held high until a signal is sent. Then a string of five zeros is sent to signify a command is coming. Then the hex code is sent but instead of sending a ‘1’ a ‘1110’ is sent and rather than a ‘0’ a ‘10’ is sent. So \$85 looks like this:

Binary:     1    0  0  0  0  1    0  1
Robosapien: 1110 10 10 10 10 1110 10 1110


So I tried the code below:

int bitTime=833;
int IROut =  4;

// The setup() method runs once, when the sketch starts

void setup()   {
// initialize the IR digital pin as an output:
pinMode(IROut, OUTPUT);

Serial.begin(9600);
}

void test()
{
// output high
digitalWrite(IROut,HIGH);
delay(1000);

// 5 zeros
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
digitalWrite(IROut,HIGH);
delayMicroseconds(bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
digitalWrite(IROut,HIGH);
delayMicroseconds(bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
digitalWrite(IROut,HIGH);
delayMicroseconds(bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
digitalWrite(IROut,HIGH);
delayMicroseconds(bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);

// send 1110 10 10 10 1110 10 1110

// 1110
digitalWrite(IROut,HIGH);
delayMicroseconds(3*bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
// 10
digitalWrite(IROut,HIGH);
delayMicroseconds(bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
// 10
digitalWrite(IROut,HIGH);
delayMicroseconds(bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
// 10
digitalWrite(IROut,HIGH);
delayMicroseconds(bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
// 1110
digitalWrite(IROut,HIGH);
delayMicroseconds(3*bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
// 10
digitalWrite(IROut,HIGH);
delayMicroseconds(bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);
// 1110
digitalWrite(IROut,HIGH);
delayMicroseconds(3*bitTime);
digitalWrite(IROut,LOW);
delayMicroseconds(bitTime);

// output high
digitalWrite(IROut,HIGH);
delay(1000);
}

void loop()
{
test();
}


But unfortunately I am not getting any response from the Robosapien. What am I doing wrong?

• Uhm... are you using external components to modulate the IR signal over the 39.something KHz carrier? – Axeman Oct 11 '12 at 14:28