Hello,
I am trying to send IR commands to a Robosapien (first generation) but I am unable to get any response from the toy.
I read that in order to send a code like 0x85 (right-arm-in), you have to send:
Binary: 1 0 0 0 0 1 0 1
IR Code: 1110 10 10 10 10 1110 10 1110
(ie., a '1110' for a '1' and '10' for a '0')
Also, I read that you have hold the input high and send a string of five '0' pulses before sending a command.
So accordingly, I tried the following code:
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);
}
// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IROut, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
digitalWrite(IROut, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}
void test()
{
// send high
//pulseIR(
pulseIR(1000*bitTime);
for(int i = 0; i < 4; i++) {
delayMicroseconds(bitTime);
pulseIR(bitTime);
}
delayMicroseconds(bitTime);
// burp: C2
// 1 1 0 0 0 0 1 0
// send 1110 1110 10 10 10 10 1110 10
pulseIR(3*bitTime);
delayMicroseconds(bitTime);
pulseIR(3*bitTime);
delayMicroseconds(bitTime);
pulseIR(bitTime);
delayMicroseconds(bitTime);
pulseIR(bitTime);
delayMicroseconds(bitTime);
pulseIR(bitTime);
delayMicroseconds(bitTime);
pulseIR(bitTime);
delayMicroseconds(bitTime);
pulseIR(3*bitTime);
delayMicroseconds(bitTime);
pulseIR(bitTime);
delayMicroseconds(bitTime);
pulseIR(1000*bitTime);
// wait for 1 sec
delay(1000);
}
void loop()
{
test();
}
But I don't get any response. I'd appreciate any helping in sending the IR codes to the robot.
Thanks