Arduino and Gobetwino Program Control via buttons.

I tried to write a code that when a certain button is pressed it serial prints a command to Gobetwino and start a song in winamp. I'm using two pin buttons. I had used these buttons for button debouncing with success. I can't seem to get success with these two programs. here is the code.

const int buttonPin1 = 7;
const int buttonPin2 = 6;
const int buttonPin3 = 5;
int buttonState;
int lastButtonState = LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;
void setup()
{
Serial.begin(9600);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);

}

void loop(){
buttonState = digitalRead(buttonPin1);

if (buttonState == HIGH) {
Serial.println("#S|MUSIC|[]#");

}
}

If you send the command once through gobetwino it works?

MIssing in your code is the previous state of the button. By adding a previous state you prevent bouncing and you will get that bit extra control you need. The snippet below gives you direction, so give it a try.

(code incomplete)

int prev_state = LOW;
void loop()
{
   buttonState = digitalRead(buttonPin1);
   if (buttonState == HIGH && prevState == LOW)
   { 
     Serial.println("#S|MUSIC|[]#");
     prevState = HIGH;
  } 
 .... etc


}

Did you configure the serial port settings in GoBetwino?

Which commandtype did you ue in GoBetwino, and how did you set it up?

What does GoBetwino write in the top status window ?

Does it recieve the command ?
Does it parse ok ?
Does it execute it ?

@MikMo yes I configured it correctly. I had it working with a simple piece of code before. when I hit the reset button it would restart the sketch and execute a program.

I'm trying the code now to see if it works. And after I will test it. If it does work. I will complete the sketch based on that first bit. I will also post here if it Works.

there is the code. As soon as I open gobetwino it executes the command with out me pressing the button.
the button I'm using is a standard two pin one. like in the photo below.

int buttonPin = 8;
int button_state = LOW;
int buttonState;
int lastButtonState = LOW;
void setup(){
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}

void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && lastButtonState == LOW)
{
Serial.println("#S|MUSIC|[]#");

}

}

2pin push button-80x80.jpeg

Are you pulling the switch high or low with a pull up / down resistor?

Can you post a schematic of how you hooked up things?