from Maix import GPIO
from fpioa_manager import fm
import _thread
import time
fm.register(24, fm.fpioa.GPIOHS24, force=True)
fm.register(25, fm.fpioa.GPIOHS25, force=True)
fm.register(26, fm.fpioa.GPIOHS26, force=True)
led_r = GPIO(GPIO.GPIOHS24, GPIO.OUT)
led_g = GPIO(GPIO.GPIOHS25, GPIO.OUT)
input = GPIO(GPIO.GPIOHS26, GPIO.IN)
def flash_led_r(status):
while True:
led_r.value(status)
status = 0 if (status==1) else 1
time.sleep_ms(100)
def flash_led_g(status):
while True:
led_g.value(status)
status = 0 if (status==1) else 1
time.sleep_ms(500)
_thread.start_new_thread(flash_led_r,(0,))
_thread.start_new_thread(flash_led_g,(1,))
while True:
time.sleep(1)
fm.unregister(24, fm.fpioa.GPIOHS24)
fm.unregister(25, fm.fpioa.GPIOHS25)
fm.unregister(26, fm.fpioa.GPIOHS26)
嘉楠k210 多线程 点亮流水灯
最新推荐文章于 2023-05-06 16:33:28 发布