Robosapian v2 PC control/New Toy

I know I havnt posted any posts in a while, but been busy working with a new project. I recently came across a robosapian v2 that someone tossed in the trash, that I rescued and got working again. The only thing is, he had no remote, so this is what I did to get control of him using the computer.

I rewired him and replaced all of the original and crumbling wires, and cleaned out the battery compartments since the batteries had exploded inside of him, then I found the wire running from his IR sensor to the motherboard inside of his back. I cut the wire and added a normally closed mono headphone jack, the type that when nothing’s plugged in, it shorts the two contacts together. The contact that gets disconnected, I ran to the IR sensor, then the other, I ran to the motherboard so the tip of the headphone jack will connect into the motherboard when it’s plugged in, and will disconnect the IR sensor so there is no false signals coming from the IR sensor in the head while it’s plugged in, then it will connect back up the IR sensor in the head when the headphone jack isnt plugged in. I put the headphone jack into his back, he usually has something that looks like a button on his back and front, but I just popped the one out on his back, and drilled it out slightly to put the jack in it, and now it looks like it was just designed into it by default.

Then I took an arduino and on a protoboard I found for dirt cheap on ebay, I soldered another headphone jack to it with 3 pin header so you can use it as you wish. I then used a 1.8k ohm resistor and a 3.3k ohm resistor to hook up a voltage divider between pin 13 and gnd, and the divided voltage went to the tip of the headphone jack on the protoshield.

Using this code below, I am able to send commands to the robosapian v2 by a python program called that I found online, Ill post a link to it below also. I had to modify the code slightly because newer arduino software deprecated a few things that was in the old code.

// rs_commander.c - Arduino-based serial port controller for Robosapiens
// Modified: 9/15/10
// Author: Ben Bongalon (
// Adapted from Karl Castlet's code
// I refactored it a bit and added support for the Robosapien V2 and
// other models (untested).
// Robosapien's model types. Credit to AiboPet's BoneYard
#define RS_MODEL_ROBOSAPIEN_V1   0x00
#define RS_MODEL_ROBORAPTOR      0x01
#define RS_MODEL_ROBOPET         0x02
#define RS_MODEL_ROBOSAPIEN_V2   0x03
#define RS_MODEL_ROBOREPTILE     0x04
#define RS_MODEL_RSMEDIA         0x05
#define RS_MODEL_ROBOQUAD        0x06
#define RS_MODEL_ROBOBOA         0x07
#define RS_BIT_HIGH    1
#define RS_BIT_LOW     0
// User-configurable parameters
int RSModel = RS_MODEL_ROBOSAPIEN_V2;  // your Robosapien model
boolean RSEcho = true;          // echo commands to host PC?
int irSignalPin = 2;             // Infrared wire connects to this Pin
int ctrlPin = 13;                // Generate the pulses on this Pin
volatile int RSIRCommand;        // Single byte command from IR
volatile int RSBit=9;            // Total bits of data
boolean RSIRCommandReady=false// IR command was received?
int bitTime = 833;               // bit width in microseconds (1/1200 second clock)
#define INTER_CMD_TIME    10     // msecs before sending next command
// Encode a binary '1' or '0' on the wire
void WriteBit(int bit)
  digitalWrite(ctrlPin, HIGH);
  delay_ticks((bit == RS_BIT_HIGH) ? 4 : 1);
  digitalWrite(ctrlPin, LOW);
// Send a byte down the wire (MSB first)
void WriteByte(byte b)
    WriteBit( (b & 0x80) == 0x80 );
    WriteBit( (b & 0x40) == 0x40 );
    WriteBit( (b & 0x20) == 0x20 );
    WriteBit( (b & 0x10) == 0x10 );
    WriteBit( (b & 0x08) == 0x08 );
    WriteBit( (b & 0x04) == 0x04 );
    WriteBit( (b & 0x02) == 0x02 );
    WriteBit( (b & 0x01) == 0x01 );
// Start each Robosapien commands with a preamble
void WritePreamble()
   // Pull down the I/O line for 8 ticks
   digitalWrite(ctrlPin, LOW);
   // Send the Robosapien model type (not needed for the orginal Robosapien)
   if (RSModel != RS_MODEL_ROBOSAPIEN_V1) {
     WriteBit( (RSModel & 0x08) == 0x08 );
     WriteBit( (RSModel & 0x04) == 0x04 );
     WriteBit( (RSModel & 0x02) == 0x02 );
     WriteBit( (RSModel & 0x01) == 0x01 );
// Add N clock ticks of delay
void delay_ticks(int ticks)
// Receive a bit at a time.
void RSReadCommand()
  delayMicroseconds(bitTime + bitTime/4);      // about 1 1/4 bit times
  int bit = digitalRead(irSignalPin);
  if (RSBit==9) { // Must be start of new command
    RSIRCommandReady = false;
  if (RSBit<8) {
    RSIRCommand <<= 1;
    RSIRCommand |= bit;
  if (RSBit==9) {
void RSSendCommand(int opcode)
  WriteByte(opcode & 0xFF);
  digitalWrite(ctrlPin, HIGH);
  if (RSEcho) {
  delay(INTER_CMD_TIME);    // buffer time before processing next command
// Initialize the serial port, GPIO pins and interrupts
void setup()
  pinMode(irSignalPin, INPUT);
  pinMode(ctrlPin, OUTPUT);
  digitalWrite(ctrlPin, HIGH);
// Main program loop
void loop()
  // If a command was received from the IR remote, relay it to the robot
  if (RSIRCommandReady) {
  // otherwise, check the serial port for new commands sent by computer
  else if (Serial.available() > 0) {
    int opcode =;

And here is the link for

Ill try to post pictures later, but dont feel like tearing him all back apart again atm. 😛

ps, if your having trouble with the code I posted, just grab the code from the site with robomoco, under the part 1 link,  and look for “serial.print(opcode, BYTE” and change it to “serial.print(opcode)”, then it should compile fine.


16 Responses to Robosapian v2 PC control/New Toy

  1. BenB says:

    So nice of you to rescue a Robosapien V2! They are a rare breed nowadays… you are guaranteed a place in robot heaven 🙂

    Thanks for using my code…. I’m glad it found a good use especially on a cool project like yours.


  2. David says:

    I know its been a while since anyone did any work on this but do you happen to have a copy of the code? The link is long since dead and I am trying to emulate what you did with the Robosapien V2.
    All the Best

    • Ben Bongalon says:

      Hi David, Yes I shut down my site a while ago, but let me look thru my file archives tonight and get back to you. Glad to know you saved an RSV2. 🙂


      • David says:

        Hi Ben, thanks for looking that is much appreciated. I was given a RSV2 in a bad state and have rewired it and got it to power up but I don’t have a controller so I can’t test it any further and was hoping to use your code to make a start on control from a raspberry pi or similar.
        All the best

      • cae2100 says:

        I just saw your messages guys and zipped up my RS folder for you guys, here is the program and together. Also, the code above is the same as ben had uploaded on his site, but updated to run for the new arduino software since some commands were no longer supported, so the commands were changed to the updated versions.

        I was also playing with something a while back and was trying to control the robosapien using IR by hooking IR leds up to the arduino through a transistor, and I got it working on the robosapien V1 but never really messed around with it much, here’s what I have if you want to play with it too. I added RSV2 commands into it but I could never get it to work, but I believe I disconnected my IR reciever in RSV2, but not really sure, your welcome to play with it if you wish. I just used it with an arduino chip to build my own basic remote control.

        Have fun.

      • BenB says:

        @cae2100: Thanks for sharing the files. I knew it was backed up somewhere 🙂
        Kudos on the mods too. You guys are inspiring me to dabble with my RSV2 again.


  3. David says:

    Hi cae2100 & Ben,
    Fantastic – Thanks for taking the trouble to get this back out for me. I’m inspired and can see a few late nights looming!!
    Will let you know how I get on.

  4. David says:

    Hi – I noticed that the code in the irremote.cpp file for RSV2 uses “unsigned char” statement. This will give a problem with numbers greater than 255. You can see that if you give the decimal for the $350 (dance) command you actually send decimal 80 instead of 848. I changed it to int and it corrected it to output 848 as required. Hope this makes sense.
    Best regards

    • cae2100 says:

      yep, makes perfect sense and I hope that it works good for you for the IR remote so you can create your own remote control for your RS. Also, thanks for finding that, I got stuck on that and eventually gave up on trying to control RSV2 with IR bc I couldnt get it to work and the project went on the backburner. Now Ill try to figure out if I can remotely control my RSV2 without the cable, and if so, that would be awesome to build a remote for him too now.

      Thanks again!
      Also, after thinking about it, with your mod, you can now add the codes for any of the wowee toys fairly easily.

      • David says:

        I’m working on replacing the RSV2 IR control with a NRF24 module and arduino. This will give better comms reliability and greater range than can be achieved with IR. Once I have managed to talk to the RSV2 using the codes given I can work on the rest. I am also thinking of hooking up a small OLED type display to indicate the code sent and battery voltage etc.
        Should keep me busy in the winter evenings!

  5. tommywu says:

    Hi ,thanks for those great info since I just got an old one . I want to know how to connect RS v2 via serial port with arduino?

    • cae2100 says:

      I had tapped into the data line in between his head, from the IR sensor to the main board in him for the longest time, then used a cable between the two. Later on, I came up with a way to control the robosapien robots using the actual IR control through arduino, and there is a bit of stuff out there on that based on a modified IR library for arduino.

      Here’s a link to the IR library and such.

      • tommywu says:

        Hi , thanks for your info . I have tried your code for rsv2. With bad luck . I still can not control rsv2 via IR transmitter on arduino. for the data sent. I just need to send 848 for dance ? or any value I have to prefix it ?

      • tommywu says:

        I have successfully decode the rsV2 IR code. I have modified your IRremote.cpp since you have wrong mark & sapce for V2. thanks your help.

      • cae2100 says:

        Would you mind posting your modifications or what you had to do for future reference to people trying to mess with the RSv2 IR code?

  6. tommywu says:

    Hi , just modified the IRremoteInt.h as below , you have wrong RS_HDR_SPACE.fix it then it will work.

    // Robosapien V2 Remote
    #define RS_HDR_MARK 6500
    #define RS_HDR_SPACE 850 // As 1 as well but always in same position
    #define RS_BIT_MARK 800
    #define RS_ONE_SPACE 3400
    #define RS_ZERO_SPACE 850

    Video :

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: