arduino, sensor box and a button
Hi, I'm looking for a realize a simple series of button to launch samples using arduino and sensor box. the problem is that everytime I push the button, obviously arduino send a fast sequence of 0 and 1, so my sample start and stop. when I push a button, I need only one 1, not a series of 1 and 0. any suggestion?
[change] is your friend ;)
you rock!
thank you
Thanx! ;)
Another way would be to alter your Arduino script in that way that you only print to the serial port if the value has changed.
int oldButtonState = 0;
int buttonState = 0;
[...]
void loop() {
buttonState = digitalRead();
if (oldButtonState != buttonState {
Serial.write(buttonState);
oldButtonState = buttonState;
}
}
[this is untested just dirty coding to explain the mechanism]
It will have the same effect at then but be slightly more elegant, as you avoid unnecessary data transfer.
Jan
you right, and I'm a bit lazy on arduino programming. I'm building a simple system, maybe with time I will build a similar system using only arduino, I'm trying this code on sensor box...