Skip to content

Instantly share code, notes, and snippets.

@neosarchizo
Created July 26, 2022 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neosarchizo/472db0c6d20a6d0f03700b02be3e2150 to your computer and use it in GitHub Desktop.
Save neosarchizo/472db0c6d20a6d0f03700b02be3e2150 to your computer and use it in GitHub Desktop.
MicroPython - ESP32 인터럽트 제어하기
from machine import Pin
from time import sleep_ms
led = Pin(2, Pin.OUT)
key = Pin(0, Pin.IN, Pin.PULL_UP)
state = 0
def on_falling(_):
global state
sleep_ms(10)
if key.value() == 0:
state = not state
led.value(state)
key.irq(on_falling, Pin.IRQ_FALLING)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment