from machine import Pin
import time
# Menentukan nomor GPIO untuk LED dan tombol tekan
nomor_led = [3, 5, 6, 8, 7, 16] # Enam pin output untuk LED
nomor_tombol = [11, 20] # Dua pin input untuk tombol tekan
# Mengonfigurasi LED sebagai output
led = [Pin(pin, Pin.OUT) for pin in nomor_led]
# Mengonfigurasi tombol sebagai input dengan resistor pull-down
tombol = [Pin(pin, Pin.IN, Pin.PULL_DOWN) for pin in nomor_tombol]
while True:
# Jika tombol pertama ditekan, aktifkan tiga LED pertama
if tombol[0].value() == 1:
led[0].on()
led[1].on()
led[2].on()
else:
for i in range(3):
led[i].off()
# Jika tombol kedua ditekan, aktifkan tiga LED berikutnya
if tombol[1].value() == 1:
led[3].on()
led[4].on()
led[5].on()
else:
for i in range(3, 6):
led[i].off()
time.sleep(0.05) # Penundaan untuk mengurangi efek bouncing pada tombol