# ex_2_3_07_button_internal_pullup.py (จำลอง: https://wokwi.com/projects/469814308552046593)
from machine import Pin
import time
led = Pin(12, Pin.OUT)
button = Pin(4, Pin.IN, Pin.PULL_UP)
while True:
if button.value() == 0: # ตรวจพบการกด (Active-Low)
led.on()
else:
led.off()
time.sleep_ms(20) # debounce อย่างง่าย: หน่วง 20 ms กรองการสั่นของหน้าสัมผัส