arduino, sensor box and a button

    Jun 22 2011 | 11:18 am
    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?

    • Jun 22 2011 | 11:58 am
      [change] is your friend ;)
    • Jun 22 2011 | 12:32 pm
      you rock! thank you
    • Jun 22 2011 | 12:43 pm
      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.
    • Jun 22 2011 | 5:01 pm
      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...