[Project sharing] Example of K210 -- water lamp V1

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
sipeed76
Posts: 7
Joined: Tue Mar 16, 2021 6:16 am
Contact:

[Project sharing] Example of K210 -- water lamp V1

Post by sipeed76 » Thu Mar 18, 2021 8:07 am

The required libraries are GPIO, FPIOA_MANAGER, UTIME supplement:
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

User avatar
sipeed76
Posts: 7
Joined: Tue Mar 16, 2021 6:16 am
Contact:

[Project sharing] Arduino&K 210&infrared tube triad voice control obstacle avoidance car

Post by sipeed76 » Thu Mar 18, 2021 3:52 pm

Image

The car can normally complete the function of turning left or right forward or backward:

https://www.bilibili.com/video/BV1kU4y1 ... e_k=I23r8F

The obstacle avoidance function test of the car is normal:

https://www.bilibili.com/video/BV1Fp4y1 ... e_k=k83Oo9

The above is my first time to do the results of the car, to be improved

Post Reply