嘉楠k210 kd233官方demo板gpio点灯实验

使用maixpy  micropython开发

import utime
from Maix import GPIO
from board import board_info
from fpioa_manager import fm

# register pin to gpiohs0, 
# arg force means force register no matter we have registered before or not
# if arg force=False(by default), register func will return a tuple that registered info,
#                                                           or return number 1
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)

i = 0
status = 0
while True:
    led_r.value(status)
    led_g.value(status)
    print("LED :", led_r.value())
    print("-----input:", input.value())
    i+=1
    status = 0 if (status==1) else 1
    utime.sleep_ms(200)

fm.unregister(24, fm.fpioa.GPIOHS24)
fm.unregister(25, fm.fpioa.GPIOHS25)
fm.unregister(26, fm.fpioa.GPIOHS26)

原理图

嘉楠k210 kd233官方demo板gpio点灯实验_第1张图片

板子效果

嘉楠k210 kd233官方demo板gpio点灯实验_第2张图片

你可能感兴趣的:(gpio,jquery,java,swift,perl)