void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(8, INPUT_PULLUP);
}
void loop() {
// put your man code here, to run repeatedly:
// mendeklarasikan variabel
//untuk membaaca keadaan tombol
bool tombol;
bool lampu;
//membaca keadaan tombol
//jika saklar ditekan, variabel tombol bernilai LOW
//jika saklar tidak ditekan,variabel tombol bernilai HIGH
tombol= digitalRead(8);
lampu = digitalRead(2);
if (tombol == LOW) {
if (tombol == LOW)
digitalWrite(2, HIGH);
}
else {
digitalWrite(2, LOW);
}
}