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);
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
}
@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|[]#");