i've tried another way, and it's working a lot better,
However, it has a big delay, about 2 seconds before it registers a button press and displays the text,
it's probably a silly mistake, but i am not sure what it is,
and not sure i can do this kind of sketch with a button matrix,
#include <LiquidCrystal.h>
int buttonPin1= 6;
int buttonPin2= 7;
int buttonPin3= 8;
int buttonPin4= 9;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int prevButtonState1;
int prevButtonState2;
int prevButtonState3;
int prevButtonState4;
void setup()
{
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
digitalWrite(buttonPin1, LOW);
digitalWrite(buttonPin2, LOW);
digitalWrite(buttonPin3, LOW);
digitalWrite(buttonPin4, LOW);
lcd.begin(20, 1);
lcd.print("Omsi Almex a90");
delay(2000);
lcd.clear();
}
void loop(){
int buttonState1 = digitalRead(buttonPin1);
int buttonState2 = digitalRead(buttonPin2);
int buttonState3 = digitalRead(buttonPin3);
int buttonState4 = digitalRead(buttonPin4);
if (buttonState1 == LOW && prevButtonState1== HIGH){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Fahrschein Nor 2.70");
prevButtonState1 = buttonState1;
}
else if(buttonState2 == LOW && prevButtonState2== HIGH){
lcd.clear();
lcd.print("Fahrschein Erm 1.70");
prevButtonState2 = buttonState2;
}
else if(buttonState3 == LOW && prevButtonState3== HIGH){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Tageskarte 9.00");
prevButtonState3 = buttonState3;
}
else if(buttonState4 == LOW && prevButtonState4== HIGH){
lcd.clear();
lcd.print(" >>Drucken<< ");
delay(2000);
lcd.clear();
prevButtonState4 = buttonState4;
}
else{
prevButtonState1 = buttonState1;
prevButtonState2 = buttonState2;
prevButtonState3 = buttonState3;
prevButtonState4 = buttonState4;
}
}