const int tombol = 4; //membuat variabel “tombol” yang bernilai 4
const int ledTest = 5; //membuat variabel “ledtest” yang bernilai 5
int bacaTombol = 0; //membuat variabel “bacaTombol” yang bernilai 0
int statusTombol = 0; //membuat variabel “statusTombol” yang bernilai 0
void setup() {
pinMode(tombol, INPUT);
pinMode(ledTest, OUTPUT);
}
void loop() {
bacaTombol= digitalRead(tombol);
if(bacaTombol == HIGH) {
statusTombol = 1;
}
if(statusTombol==1) {
digitalWrite(ledTest, HIGH);
}
else
{
digitalWrite(ledTest, LOW);
}
}