Go Down

Topic: LyquidCristal / 10-1 = 90? (Read 623 times) previous topic - next topic

PaulS

Quote
For your next lesson,  read up on debouncing  and on interrupts 

There is no reason to be using interrupts to read switches pressed by humans.

aufruf


Quote
OP: http://arduino.cc/en/Tutorial/ButtonStateChange might be of interest.


Hi Paul,

thanks a lot for the tip. This is what my code now looks like and works like a charm. Many thanks!

Code: [Select]
void loop() {
lcd.setCursor(0,1);

lcd.print(value);
lcd.print(" "); // Overwriting Zero

buttonState = read_LCD_buttons();

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
         // if the state has changed, perform action
         if (buttonState == btnUP) {
value = value+1;
         }
         if (buttonState == btnDOWN) {
value = value-1;
         }
}

lastButtonState = buttonState; 
}

Go Up