Some hexy the hexapod notes on getting hexy to run with App Inventor 2

Sooo… the wife bought a hexy the hexapod for the daughter and me for christmas. (Basically the wife wanted it to be for both of us since she was concerned that our daughter wouldn’t let me play with it.

Hexy is assembled and had a usb cable sticking out of his hind quarters but I’ve managed to give him a little dignity and I got the Bluetooth running. We started with 4 alkaline batteries and I was getting the dead bug phenomena. So I ran out to home depot and picked NIMI the rating is about 1400 mAH. That’s under the capacity of Arcbotics suggested Actually there was some 2300Mah that I should have gotten.

One of the things that I’ve been thinking being to do some programming of the hexy from MITS application inventor. At this point, I want to figure out the command syntax that goes into the controller.
The data stream is decoded here: https://github.com/ArcBotics/Servotor32/blob/master/Code/Servotor32_Default/Servotor32.cpp

void Servotor32::process(Stream *serial){
  if(serial->available()) { //process input from the USB
    char inChar = (char)serial->read();
    switch(inChar){
      case '#':
        servoCounting = true;
        numCount = 0;
        inServo = -1;
        inPos = -1;
        break;
      case 'D':
        printStatus(serial);
        break;
      case 'P':
        if(servoCounting){
          inServo = tallyCount();
          servoCounting = false;
        }
        posCounting = true;
        numCount = 0;
        break;
      case '\r':
      case '\n':
        if(posCounting){
          inPos = tallyCount();
          posCounting = false;
        }
        if((inServo >=0)&&(inServo <=31)&&(((inPos >= 500)&&(inPos <= 2500))||(inPos == -1))){
          changeServo(inServo,inPos);
          inServo = -1;
          inPos = -1;
        }
        numCount = 0;
        break;
      case 'V':
        serial->println("SERVOTOR32_v2.0");
        break;
      case 'C':
        for(int i=0; i<32; i++){
          changeServo(i, 1500);
        }
        serial->println("All Centered");
        break;
      case 'K':
        for(int i=0; i<32; i++){
          changeServo(i,-1);
        }
        serial->println("All Turned Off");
        break;
      case 'L':
        if(servoCounting){
          inServo = tallyCount();
          servoCounting = false;
        }
        changeServo(inServo, -1);
        break;
      default:
        if((inChar > 47)&&(inChar < 58)){
          if(numCount<4){
            numString[numCount] = inChar-48;
            numCount++;
          }
        }
        break;
    }
  }
}

Rather than trying to figure out the code. I took a look at the Pomoco python script which generates this stuff to be coded.
If you change change debug = true in servotorComm.py you get the commands that are being sent to the controller via the usb cable.

I ran across some hexy code that runs on my Nexus 7 pad here: https://code.google.com/p/andmoco/
I got the bluetooth working on hexy and it seemed to work.. Although, it seems like the code isn’t quite right. It seems like hexy walking was screwed up.

Anyway.. I’m tired.. and its time for bed.. I hope what I’ve written makes sense.
I think my next baby step in my android adventure to to see is the following.

Establish a bluetooth connection from App inventor to hexy.
See if I can get hexys head to rotate via App Inventor coding.

After that I get that accomplished, I’m thinking that I want to see if I can figure out how to link external code to App Inventor 2. I’m thinking either python or java.. which ever works easier.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *