#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 6, 2);
int x=2; //button is connected to digital pin 2
int val=0,led_num=0;
void setup()
{
lcd.begin(16,2);
lcd.backlight();
}
void loop()
{
//read the value of the button when pressed
val=digitalRead(x);
if(val==1){ //button is pressed
led_num=led_num+1; //add 1 to the led_num variable
}
if (led_num==1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Selamat Datang ");
}
else if (led_num==2){
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Haya Asyifa");
}
else if (led_num==3){
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" D4 TRSE");
//reset the led_num variable to 0
led_num=0;
}
//wait 300 ms for the next reading
delay(800);
}