Pages: [1]   Go Down
Author Topic: Arduino + Robosapien = BoBo  (Read 2047 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Named by my flat mate, I've managed to interface an arduino with a robosapien v1 by tapping into the IR In line and pulsing a line to simulate commands (originally they would come from the remote control). I've set it up so you pass a number by serial and it converts this into binary, moves through the binary and pulses the appropriate code. Now to start making it do more!
Will add some pictures later.

Code:
int outPin = 8;                 // digital pin 8
int code = 0;
char str1[3];
int count = 0;
char incomingByte;

void setup()
{
  pinMode(outPin, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);
}

void lowBit()
{
  digitalWrite(outPin, HIGH);    // sets the pin off
  delayMicroseconds(750);
}

void clockBit()
{
  digitalWrite(outPin, LOW);    // sets the pin off
  delayMicroseconds(1150);
}

void startBit()
{
  digitalWrite(outPin, LOW);   // sets the pin on
  delayMicroseconds(5000);        // pauses for 50 microseconds        
}

void highBit()
{
  digitalWrite(outPin, HIGH);   // sets the pin on
  delayMicroseconds(2550);
}
void loop()
{
char str1[3];
count = 0;
  while (Serial.available () > 0)
    {
      // read the incoming byte:
      incomingByte = Serial.read ();

      // Store it in a character array
      str1[count] = incomingByte;
      count++;
    }
  code = atoi(str1);
  Serial.print("B");
  Serial.println (code, BIN);
  digitalWrite(outPin, HIGH);
  delay(1000);
  startBit();
  if (code & B10000000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B01000000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
   if (code & B00100000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B00010000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B00001000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B00000100)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
   if (code & B00000010)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B00000001)
    {
      highBit(); // 1i
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  digitalWrite(outPin, HIGH);
  delay(5000);
}

Useful links:
http://evosapien.com/robosapien-hack/knitsu/html/basicx-24.html
http://users.bigpond.net.au/robert_gatt/robosapien/robosapien.htm
« Last Edit: December 21, 2007, 01:05:38 pm by jamescoxon » Logged

Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 25
Robots rock
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks very interesting. Can't wait to see some pictures/video!
Logged

Visit my robotics blog at http://megabotblog.blogspot.com/

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

More of an update, I've developed the code to wait for input of a number (which corresponds to a command) however if there is no input after a period of time the arduino programs the robosapien to go into Guard Mode (http://www.wowwee.com/robosapien/pdf/RSSentrySecret_117_04.pdf) where it'll roar and attack any loud noise made in front of it.


Code:
int outPin = 8;                 // digital pin 8
int ledPin= 12;
int codeInt = 0;
char str1[3];
int count = 0;
int guardCount = 0;
char incomingByte;
int guardArray[] = {148, 192, 171, 206, 171, 200, 167, 142, 144, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148};
int j;

void setup()
{
  pinMode(outPin, OUTPUT);      // sets the digital pin as output
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);
  digitalWrite(ledPin, LOW);   // sets the LED on
  Serial.begin(9600);
}

void lowBit()
{
  digitalWrite(outPin, HIGH);    // sets the pin off
  delayMicroseconds(750);
}

void clockBit()
{
  digitalWrite(outPin, LOW);    // sets the pin off
  delayMicroseconds(1150);
}

void startBit()
{
  digitalWrite(outPin, LOW);   // sets the pin on
  delayMicroseconds(5000);        // pauses for 50 microseconds        
}

void highBit()
{
  digitalWrite(outPin, HIGH);   // sets the pin on
  delayMicroseconds(2550);
}

void IRcode(int code)
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  digitalWrite(outPin, HIGH);
  delay(1000);
  startBit();
  if (code & B10000000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B01000000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
   if (code & B00100000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B00010000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B00001000)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B00000100)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
   if (code & B00000010)
    {
      highBit(); // 1
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  if (code & B00000001)
    {
      highBit(); // 1i
      Serial.print("1");
      clockBit();
    }
  else
  {
  lowBit(); // 0
  Serial.print("0");
  clockBit();
  }
  digitalWrite(outPin, HIGH);
  digitalWrite(ledPin, LOW);   // sets the LED off
}

void guardMode()
{
      Serial.println("Guard Mode");
      IRcode(142);
      for (j = 0; j < 23; j = j + 1) {
        IRcode(guardArray[j]);
      }
}

void loop()
{
  char str1[3] ="00";
  count = 0;
  codeInt = 0;
  while (Serial.available () > 0)
    {
      // read the incoming byte:
      incomingByte = Serial.read ();
      // Store it in a character array
      str1[count] = incomingByte;
      count++;
    }
    codeInt = atoi(str1);
    Serial.print("B");
    Serial.println (codeInt, BIN);
    if (codeInt > 0)
    {
    if (codeInt > 998)
    {
      guardMode();
    }
    else {
    IRcode(codeInt);
    guardCount = 0;
    }
    Serial.flush();
    }
    else {
      Serial.println("Sleeping");
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(1000);
      digitalWrite(ledPin, LOW);   // sets the LED off
      delay(1000);
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(1000);
      digitalWrite(ledPin, LOW);   // sets the LED off
      delay(2000);
      if (guardCount > 5)
      {
        guardMode();
        guardCount = 0;
        digitalWrite(ledPin, HIGH);   // sets the LED on
        delay(2000000);
        digitalWrite(ledPin, LOW);   // sets the LED off
      }
      guardCount++;
    }
}
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Whoa, if i get the time ill build this i just got my arduino smiley also i have the Robosapien he is fun lol
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What exactly does bobo do :o? :-X
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To tell you the truth not much!

I've now added a radiomodem so that I can control it wirelessly - the 'robot/toy' has a load of built-in commands such as walk forward or move left arm which can be now controlled from a computer. The plan now is to add some sensors so that it knows where it is and then perhaps a little intelligence - who knows.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know it's been a while since anyone posted in this thread, but i have recently picked up a robosapien and a roboquad for next to nothing.  The robosapien actually is complete and works perfectly.  The roboquad suffered a size 12 shoe to the remote, and lost all of it's transistorized goodness.  So I can't control it at all.  I know the quad works for sure... just no remote.

I found this thread with the thought of being able to program the rsv1 or rquad with the arduino's that i already have.  

I can't get the codes above to work at all.  I have tapped the white ir wire in the head.. attached to pin 8.  I thought at first that i had the wrong end of the wire attached to the pin.  It doesn't make a difference what pin i use.

Has anyone used this code succesfully?

Any help appreciated.
Logged

Pages: [1]   Go Up
Jump to: