gobetwino erro with excel sheet

Ok I am trying to use gobetwino to pull up and excel sheet with my accelerometer.

I have a code but I am getting an error in the gobetwino window. this is the only problem I am having.

This is the error

6/9/2010 3:54:59 PM Executing command : SENDK
6/9/2010 3:54:59 PM Sending keys to process 0 failed
6/9/2010 3:54:59 PM Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

I should get data like
x y z
25 -14 -472
22 -13 -473
21 -13 -474
24 -14 -472 ect.
here is my code, its a lil messy, sorry

int serInLen = 25; //for opening excel program
char serInString[25]; //for opening excel program
int pId =0;
int result;
int CS_pin = 9; //Chip select input; active low
int CLK_pin = 10; // Clock input
int DIO_pin = 11; // Data to/from the modual
int aX = 0;
int aY = 0;
int aZ = 0;

void setup()
{
Serial.begin(115200); //Starting serial monitor at 115200
pinMode(CS_pin, OUTPUT);
pinMode(CLK_pin, OUTPUT);
pinMode(DIO_pin, OUTPUT);
// initialize device & reset

digitalWrite(CS_pin,LOW);
digitalWrite(CLK_pin,LOW);
delayMicroseconds(1);
digitalWrite(CS_pin, HIGH);
digitalWrite(CLK_pin,HIGH);

Serial.println("#S|SPXL|#"); // start EXCEL
readSerialString(serInString, 5000); // wait 5 seconds (max) for answer from Gobetwino (= porcess ID)
pId= atoi(serInString); // convert result to integer (from excel program?)
sendTiltValues();
}

//// LOOP
void loop() {

aX = GetValue(B1000);
aY = GetValue(B1001);
aZ = GetValue(B1010);
delay(1000); // loop every 100 times per sec.
}

//// FUNCTIONS
void StartBit() { //return no information from function StartBit()
pinMode(DIO_pin, OUTPUT); //sets DIO_pin as output
digitalWrite(CS_pin, LOW); //sets CS_pin off
digitalWrite(CLK_pin, LOW); //Sets CLS-pin off
delayMicroseconds(1); //delay for 1 microsecond
digitalWrite(DIO_pin, HIGH); //Dio_pin On
digitalWrite(CLK_pin, HIGH); //CLK-pin on
delayMicroseconds(1); //delay for 1 microsecond

}

/////////////////////////
void ShiftOutNibble(byte DataOutNibble) //return no information ShiftOutNibble: using byte of DataOutNibble
{
for(int i = 3; i >= 0; i–) //Loop, starts at 3, if it is >= O then it subtracts 1 and starts the same loop over, if it is less than ) then goes to next step.
{

digitalWrite(CLK_pin, LOW); //CLK_pin off
// set DIO first
if ((DataOutNibble & (1 << i)) == (1 << i)) // DataOutNibble AND 1 x 2^i Equals 1 x 2^i ?
{
digitalWrite(DIO_pin, HIGH);
}
else
{
digitalWrite(DIO_pin, LOW);
}
// with CLK rising edge the chip reads the DIO from arduino in
digitalWrite(CLK_pin, HIGH);
// data rate is f_clk 2.0 Mhz → 0,5 micro seeconds
delayMicroseconds(1); // :slight_smile: just nothing
}
}
////////////////////////////////////////////////////////////////////////////////
void SampleIt() //return no information from function SampleIt(),
{
digitalWrite(CLK_pin, LOW);
delayMicroseconds(1);
digitalWrite(CLK_pin, HIGH);
delayMicroseconds(1);

pinMode(DIO_pin, INPUT);
digitalWrite(CLK_pin, LOW);
delayMicroseconds(1);
digitalWrite(CLK_pin, HIGH);
if (digitalRead(DIO_pin)== LOW)
{
// Blink LED because ok
}
}
///////////////////////////////////////////////////////////////////
byte ShiftInNibble() //stores 8 bit unsigned number of ShiftNibble()
{
byte resultNibble;
resultNibble = 0;

for(int i = 3 ; i >= 0; i–)
{ // from bit 3 to 0
// The chip Shift out results on falling CLK
digitalWrite(CLK_pin, LOW);
delayMicroseconds(1); // :slight_smile: just nothing
if( digitalRead(DIO_pin) == HIGH)
{ // BIT set or not?
resultNibble += 1 << i; // Store 1 x 2^i in our ResultNibble
}
else
{
resultNibble += 0 << i; // YES this is alway 0, just for symetry :wink:
}
digitalWrite(CLK_pin, HIGH);
//delayMicroseconds(1); // :slight_smile: just nothing
}
return resultNibble; //now resultNibble
}
//////////////////////////////////////////////////////////////
void EndBit() //return no information from function EndBit(),
{
digitalWrite(CS_pin, HIGH);
digitalWrite(CLK_pin, HIGH);
}
////////////////////////////////////////////////////////////////
int GetValue(byte Command) { // x = B1000, y = B1001, z = B1010
int Result = 0;
StartBit();
ShiftOutNibble(Command);
SampleIt();
Result = 2048 - ((ShiftInNibble() << 8) + (ShiftInNibble() << 4) + ShiftInNibble());
EndBit();

return Result; //Terminate a function and return a value from a function to the calling function, if desired.
}

void sendTiltValues() //return no information from sendPotValues(), setting up def.
{
char buffer[5]; //hold 4 letters and one null character at the end to terminate the string
//declare a string with 5 characters

int aX; //potValue1 obtained from ?
int aY;
int aZ;

for (int i=1; i<=15; i++) //starting at 1, for integers less or equal to 15, add by one, loop keeps going till greater
//than 15
{
// This is the total line that is send: #S,SENDK,[pId; aY {TAB} aY {TAB} aZ {DOWN} {LEFT} {LEFT} ]#
Serial.print("#S|SENDK|["); //Send the values as though it was typed into Excell, using the SENDK command
Serial.print(itoa((pId), buffer, 10)); // print(converts integer to string)
Serial.print("&");
Serial.print(itoa((aX), buffer, 10));
Serial.print(" {TAB} “);
Serial.print(itoa((aY), buffer, 10));
Serial.print(” {TAB} ");
Serial.print(itoa((aZ), buffer, 10));

Serial.print(" {DOWN} “);
Serial.print(” {LEFT} “);
Serial.print(” {LEFT} “);
Serial.println(”]#");
// wait up to 1000 ms for answer from Gobetwino, answer will be in serInString, answer is 0 if all is OK
readSerialString(serInString, 1000);
//Deal with answer here - omitted in this example
delay(2000);
}
// Now we have sent the 2 pot values 15 times, so save and close the XL sheet.
Serial.print("#S|SENDK|[");
Serial.print(itoa((pId), buffer, 10));
Serial.print("& “);
Serial.print(”%Fg%Fa"); //= ALT f ALT g = save and exit in danish Excell
Serial.println("]#");
// Wait 2 seconds for the save to finish
delay(2000);
// wait up to 1000 ms for answer from Gobetwino, answer will be in serInString, answer is 0 if all is OK
readSerialString(serInString, 1000);
// Next e-mail the XL sheet to someone
Serial.println("#S|MXL|#");
// wait up to 1000 ms for answer from Gobetwino, answer will be in serInString, answer is 0 if all is OK
readSerialString(serInString, 1000);
}

//read a string from the serial and store it in an array
//you must supply the array variable - will return if timeOut ms passes before the sting is read so you should
//check the contents of the char array before making any assumptions.
void readSerialString (char *strArray,long timeOut)
{
long startTime=millis();
int i;

while (!Serial.available()) {
if (millis()-startTime >= timeOut) {
return;
}
}
while (Serial.available() && i < serInLen) {
strArray = Serial.read();

  • i++;*
  • }*
    }

in your void Setup() you have this (which look ok).

Serial.println("#S|SPXL|[]#");                    // start EXCEL
 readSerialString(serInString, 5000);          // wait  5  seconds (max) for answer from Gobetwino (= porcess ID)
 pId= atoi(serInString);                       // convert result to integer (from excel program?)

What does GoBetwino display in the command window when that command is recieved ?

Does Excel Start up ?

MikMo / Mikael