from machine import Pin
import time
# Daftar GPIO untuk LED dan push button
led_pins = [2, 3, 4 ] # Output LED
button_pins = [ 10, 11, 12] # Input dari push button
# Inisialisasi LED sebagai output
leds = [Pin(pin, Pin.OUT) for pin in led_pins]
# Inisialisasi push button sebagai input dengan pull-down
buttons = [Pin(pin, Pin.IN, Pin.PULL_DOWN) for pin in button_pins]
while True:
# Kontrol LED 1 dengan tombol 1 dan
if buttons[0].value() == 1:
leds[0].on()
else:
leds[0].off()
# Kontrol LED 2 dengan tombol 2 dan
if buttons[1].value() == 1:
leds[1].on()
else:
leds[1].off()
# Kontrol LED 3 dengan tombol 3 dan
if buttons[2].value() == 1:
leds[2].on()
else:
leds[2].off()
time.sleep(0.05) # Delay untuk debounce sederhana
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
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
btn3:1.l
btn3:2.l
btn3:1.r
btn3:2.r
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2