const int buttonPin = 8;
const int ledPin1 = 13;
int oldValue = LOW;
void setup()
{
Serial.begin(115200);
Serial.println("Tekan PB");
pinMode(buttonPin, INPUT);
pinMode(ledPin1, OUTPUT);
}
void loop()
{
int newValue = digitalRead(buttonPin);
if(newValue != oldValue)
{
if(newValue == HIGH)
{
Serial.println("PB Ditekan");
digitalWrite(ledPin1, HIGH);
}
else
{
Serial.println("PB Dilepas");
digitalWrite(ledPin1, LOW);
}
oldValue = newValue;
}
delay(100);
}