//set the lcd address to 0x27 for a 16 chars and 2 line display
liquidCrystal_12c(0x27,16,2);
int pb = 8; //pin button berada di pin 8
int led = 2; // pin led berada di pin 2
int statuspb = 0; // mengubah 'statuspb'menjadi variabel
void setup() {
// put your setup code here, to run once:
{
pinMode(2, OUTPUT);
pinMode(8, INPUT);
Serial.begin(9600);
lcd.begin(16,2);
lcd.backlight();
}
}
void loop() {
// put your main code here, to run repeatedly:
statuspb = digitalRead(pb);
if (statuspb == HIGH)
{
digitalWrite(2, HIGH);
Serial.println("LED ON");
lcd.println("LED ON")
}
else
{
digitalWrite(2, LOW);
Serial.println("LED OFF");
lcd.println("LED OFF");
}
}