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
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
led5:A
led5:C
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
r4:1
r4:2
r5:1
r5:2
r6:1
r6:2
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
led6:A
led6:C