int tombol = 2;
int led_hijau = 3;
int jumlahTekanan;
void setup() {
// put your setup code here, to run once:
pinMode(tombol, INPUT);
pinMode(led_hijau, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int statusTombol = digitalRead(tombol);
//perintah membuat tombol saklar
if(statusTombol==HIGH){
jumlahTekanan++;
delay(200);
if(jumlahTekanan==1){
digitalWrite(led_hijau, HIGH);
}
if(jumlahTekanan==2){
digitalWrite(led_hijau, LOW);
jumlahTekanan = 0;
}
}
//membuat led menyala ketika ditekan dan mati ketika tombol di lepas
if(statusTombol==HIGH){
digitalWrite(led_hijau, HIGH);
}
else{
digitalWrite(led_hijau, LOW);
}
}