#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
int stareled=0;
int butonNew;
int butonOld=1;
int buttonPin = 2;
int ledPin = 6;
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.clear();
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop()
{
lcd.setCursor(0,0);
butonNew=digitalRead(buttonPin);
if(butonOld==LOW && butonNew==HIGH){
if (stareled==0){
digitalWrite(ledPin, HIGH);
lcd.print("ON ");
stareled=1;
}
else {
digitalWrite(ledPin, LOW);
lcd.print("OFF");
stareled=0;
}
}
butonOld=butonNew;
delay(100);
}