Created
July 26, 2022 03:49
-
-
Save neosarchizo/472db0c6d20a6d0f03700b02be3e2150 to your computer and use it in GitHub Desktop.
MicroPython - ESP32 인터럽트 제어하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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