Thank's for reply PaulS,
But it will not work yet

With one button it works !!
But when i make this sketch for two buttons it will not work anymore,
look at this sketch :
/*
* Alternating switch
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int switchPin = 2; // switch is connected to pin 2
int switchPin2 = 4; // switch is connected to pin 4
int prevState; // variable for reading the pin status
int prevState2; // variable for reading the pin status
int currState; // variable to hold the last button state
int currState2; // variable to hold the last button state
void setup() {
lcd.init();
lcd.backlight();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(switchPin, INPUT); // Set the switch pin as input
pinMode(switchPin2, INPUT); // Set the switch pin as input
}
void loop(){
currState = digitalRead(switchPin);
if(currState !=prevState){
if(currState == LOW){
lcd.println(" ");
lcd.clear();
currState2 = digitalRead(switchPin2);
if(currState2 !=prevState2){
if(currState2 == LOW){
lcd.println(" ");
lcd.clear();
}
else {
prevState = currState;
prevState2 = currState2;
currState = digitalRead(switchPin);
if(currState !=prevState)
lcd.print(0, 0);
lcd.print("BUTTON-1=PRESSED ");
currState2 = digitalRead(switchPin2);
if(currState2 !=prevState2)
lcd.print(0, 0);
lcd.print("BUTTON-2=PRESSED ");
}
}
prevState = currState;
prevState2 = currState2;
}
This will not work , but with one button it works , when i push the button the LCD shows BUTTON-1= PRESSED
When i loss the button the lcd screen is empty , and that is what i will, but then with more buttons ????
This is working :
/*
* Alternating switch
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int switchPin = 2; // switch is connected to pin 2
int prevState; // variable for reading the pin status
int currState; // variable to hold the last button state
void setup() {
lcd.init();
lcd.backlight();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(switchPin, INPUT); // Set the switch pin as input
}
void loop(){
currState = digitalRead(switchPin);
if(currState !=prevState){
if(currState == LOW){
lcd.println(" ");
lcd.clear();
}
else {
prevState = currState;
currState = digitalRead(switchPin);
if(currState !=prevState)
lcd.print(0, 0);
lcd.print("BUTTON-1=PRESSED ");
}
}
prevState = currState;
}
Maby you can give me some information what i have to do ?
Thank's for read this !!
Patrick, The Netherlands.