The external pins and internal functions on the K210 chip are independent of each other
Pin refers to many metal contacts from the chip, that is, we commonly known as functional pins
It can be GPIO/PWM/ADC/I2C and other internal function pins. The traditional cognition is that the internal function corresponding to pins is unchangeable
But it can be reused, whereas the K210 can be mapped to change the pin function. Use the Register function to bind the pin to the function you want to implement。
Create a new SPI object using GPIO
LED lamp has three pins: LED_R, LED_G and LED_B. These three pins are bound and can be called when used
Code: Select all
'''
实验名称:流水灯
实验目的:让RGB灯循环闪烁。
'''
from Maix import GPIO
from fpioa_manager import fm
import utime
#将将LED外部IO注册到内部GPIO,K210引脚支持任意配置
fm.register(12, fm.fpioa.GPIO0)
fm.register(13, fm.fpioa.GPIO1)
fm.register(14, fm.fpioa.GPIO2)
#构建LED对象,并初始化输出高电平,关闭LED
LED_B = GPIO(GPIO.GPIO0, GPIO.OUT,value=1)
LED_G = GPIO(GPIO.GPIO1, GPIO.OUT,value=1)
LED_R = GPIO(GPIO.GPIO2, GPIO.OUT,value=1)
while True:
#蓝灯亮1秒
LED_B.value(0) #点亮LED
utime.sleep(1)
LED_B.value(1) #关闭LED
#绿灯亮1秒
LED_G.value(0) #点亮LED
utime.sleep(1)
LED_G.value(1) #关闭LED
#红灯亮1秒
LED_R.value(0) #点亮LED
utime.sleep(1)
LED_R.value(1) #关闭LED