Basic Gobetwino way of working (Help)

Hi (i'm a newbie) could you help me about a Gobetwino basic way of work?
I have a couple of importants gaps to fill before i understand the way arduino and gobetwino works together.


Gobetwino was downloaded, unziped on c:\gobetwino. and son on.
I defined GR like a SPRID command that open Guitar Ring (ACID, Reason,... any audio-like program).

(note: i can not work with gobetwino in foreground (uses COM3 Port) and upload any program to arduino: i get "the port is in use" error)

So, i defined the command on Gobetwino, and just close the program.

I upload to arduino:

void setup()
{
Serial.begin(9600);
Serial.println("#S|GR|[]#");
}

void loop()
{
}

like appears on

https://sites.google.com/a/divinechildhighschool.org/electronics/Home/Arduino-Lessons/using-gobetwino-to-control-windows-through-arduino

nothings happen. (it supposed to had to work opening Gitar Ring exec. file???)

I mean, what is the secuencial order it which i have to conf. and execute Gobetwino and upload the code to the plataform, and how is the code i have to run to , for example, execute some keystrokes under a push-button-like (http://www.arduino.cc/en/Tutorial/Button) circuit???

Thanks

GoBetwino must run all the time whwn you want Arduino to send commands to it. It can not run while the Arduino IDE is running. This is becaus they use the same serial port.

Theres no way around this.

So you need to use the Arsuini IDE to create and upload your Arduino program to your board, then close it and start GoBetwino.

Hope this helps.

OK. I'll probe it.

If i understand you, i had to go through this steps:

a) [it's done] Run Gobetwino and define SPRID command that points to Guitar Ring exec. file
b) Upload from Arduino IDE:

void setup()
{
Serial.begin(9600);
Serial.println("#S|GR|[]#");
}

void loop()
{
}

(for example)

c) close IDE and run Gobetwino

What i have to wait???
Just on the moment i run Gobetwino on c) step it launch Guitar Ring??

You will have to make sure GoBetwino is running when Arduino sends your command in the setup() section.

one way to do that is to start GoBetwino, wait a couple of secondfs and reset your Arduino board.

Don't forget to set the serial port parameters in GoBetwinos configuration menu !!!

I'm away from the internet for a few days, but will read here when i come back.

@MikMo

GoBetwino must run all the time whwn you want Arduino to send commands to it. It can not run while the Arduino IDE is running. This is becaus they use the same serial port.

The Arduino IDE only opens the serial port during the upload process. Upon completion it closes the serial port. At that time, GoBetwino should be able to run, and access the serial port, even though the IDE is still open.

Is this not what you see happening?

Yes, serial port is only busy when code is being uploaded.

Anyway, i can not fix the problem.

·) prepare the circuit (http://arduino.cc/en/uploads/Tutorial/button.png)

·) upload code (works. iI mean, the LED behavoir is the required)

/*
Button

Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 7.

The circuit:

  • LED attached from pin 13 to ground

  • pushbutton attached to pin 2 from +5V

  • 10K resistor attached to pin 2 from ground

  • Note: on most Arduinos there is already an LED on the board
    attached to pin 13.

created 2005
by DojoDave http://www.0j0.org
modified 17 Jun 2009
by Tom Igoe

This example code is in the public domain.

*/

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);

Serial.begin(9600);
Serial.print("#S|ACID|[");

}

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.print("#S|ACID|[");
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

·) OPen gobetwino (previoulsy i have define SPRID command)

i turn on the switch, but no program execute. If i disconnect arduino, and plug on again, the situation is the same

I see on serial monitor screen the command, but...

Sorry, i made a new proof. Little better.

i replace the code.....

if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.begin(9600);
Serial.println("#S|ACID|[");
delay(1000);
}

And now i receive

The Serial.begin statement should be in setup(), not loop(). You really don't want to re-initialize serial communication on every pass through loop().

Serial communication setup takes a while. The loop() function doesn't get called until it is complete, but if you want to do serial communication in setup(), as you did in the first example, you should add a delay statement (with a small value, like 100) after Serial.begin(), before Serial.print().

Or, do the Serial.print() in loop(), as you are doing in the second example.

You are missing a "]" (closing square bracket) from your Gobetwino commands.

Serial.print("#S|ACID|[");

should be:

Serial.print("#S|ACID|[]");

The situation is not so bad, but i need to unplug the board if i would run the functionality more times

Well, i am really near to fix it.
Anyway, there is a strange/erratic behavoir when code is running.

The preambles

/*
Button

Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 7.

The circuit:

  • LED attached from pin 13 to ground
  • pushbutton attached to pin 2 from +5V
  • 10K resistor attached to pin 2 from ground

http://www.arduino.cc/en/Tutorial/Button
*/

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// ADDED FROM FILE GobetwinoXLtest
//
int serInLen = 25;
char serInString[25];
int pId =0;
int result;
char buffer[5];

void setup() {
// ADDED FROM GobetwinoXLtest
Serial.begin(9600);
Serial.println("#S|ACID|[]#"); // start ACID
readSerialString(serInString, 5000); // wait 5 seconds (max) for answer from Gobetwino (=porcess ID)
pId= atoi(serInString); // convert result to integer

// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);

// Gobetwino Commands
//

// This is the total line that is send: #S,SENDK,[pId; {BS} ]#
Serial.print("#S|SENDK|[");
Serial.print(itoa((pId), buffer, 10));
Serial.print("&");
Serial.print(" {BACKSPACE} ");
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(1000);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

// ADDED FROM GobetwinoXLtest FILE
//
//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++;*
  • }*
    }
    [/quote]
    - The results
    1. If a disconnect-reconnect arduino board, and then, run Gobetwino, the program is*
  • started ok (but no {BKSP} command is sent).*
  • If a manually exec. bksp, the push button works correctly (push down --> exec BKSP over ACID)*
  • 26/07/2010 0:19:53 Serial port : COM3 opened at 9600 baud*
  • 26/07/2010 0:19:54 Commandstring recieved : #S|ACID|[]#*
  • 26/07/2010 0:19:54 Command parsed OK*
  • 26/07/2010 0:19:54 Executing command : ACID*
  • 26/07/2010 0:19:54 Process : C:\Program Files\Sony\ACID Pro 7.0\acid70.exe started. Proces ID = 0*
  • 26/07/2010 0:20:11 Commandstring recieved : #S|SENDK|[0& {BACKSPACE} ]#*
  • 26/07/2010 0:20:11 Command parsed OK*
  • 26/07/2010 0:20:11 Executing command : SENDK*
  • 26/07/2010 0:20:11 Sending keys to process 0 Succeded*
    2) If i no disconnect tha board, (really no matters if IDE is running), when i run gobetwino (ACID is not started) and push down the
  • button get back the error:*
  • 26/07/2010 0:05:02 Serial port : COM3 opened at 9600 baud*
  • 26/07/2010 0:05:03 Commandstring recieved : #S|SENDK|[0& {BACKSPACE} ]#*
  • 26/07/2010 0:05:03 Command parsed OK*
  • 26/07/2010 0:05:03 Executing command : SENDK*
  • 26/07/2010 0:05:03 Sending keys to process 0 failed*
  • 26/07/2010 0:05:03 El índice estaba fuera del intervalo. Debe ser un valor no negativo e inferior al tamaño de la colección.*
  • Nombre del parámetro: index*

In the second case i do not see this (it is there in the first example):

26/07/2010 0:19:54 Commandstring recieved : #S|ACID|[]#
26/07/2010 0:19:54 Command parsed OK
26/07/2010 0:19:54 Executing command : ACID

Which indicates that the SPRID command is not send from Arduino to GoBetwino

To send keys to a program the program must be started from Arduino with a SPRID type command, otherwise GoBetwino does not now which prohram to send the keys to.

Try to put a delay in your Setup(), between your serial start and sending the first command to GoBetwino.

It works now so fine!.
User-programs working in junction with arduino is a wide-seed idea!!

Cool.

When i made GoBetwino i had no idea how many different things people would use it for.