Here is the simple button code that I'm using.
buttonState5 = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState5 != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState5 == HIGH)
{
delay(400);
buttonPushCounter += 5;
lcd.setCursor(10,1);
lcd.print(buttonPushCounter);
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState5;
// read the pushbutton down input pin:
buttonState6 = digitalRead(buttonPin1);
// compare the buttonState to its previous state
if (buttonState6 != lastButtonState) {
// if the state has changed, decrement the counter
if (buttonState6 == HIGH)
{
delay(400);
buttonPushCounter -=5;
lcd.setCursor(10,1);
lcd.print(buttonPushCounter);
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState6;
///////////////////////////////////////////////////
////////////////////////////////////////////////////
lcd.setCursor(2, 1);
delay(3); //time for adc to settle
lcd.print(Pres3);
lcd.setCursor(2, 1);
lcd.print(" ");
lcd.setCursor(2, 1);
lcd.print(Pres3);
lcd.setCursor ( 0, 1);
lcd.print("A");
lcd.setCursor ( 1, 1);
lcd.print("=");
///Set Value Display
lcd.setCursor(12, 1);
delay(3); //time for adc to settle
lcd.print(Pres4);
lcd.setCursor(12, 1);
lcd.print(" ");
lcd.setCursor(12, 1);
lcd.print(Pres4);
lcd.setCursor ( 10, 1);
lcd.print("S");
lcd.setCursor ( 11, 1);
lcd.print("=");
if (buttonState2 == LOW) { goto KEY;
}
else if (buttonState2 == HIGH) { goto TEST;
}