Development board: K210 AIRV R3 version widora
Development environment: MaixPy IDE silicon speed home
Required reference sites:
https://cn.maixpy.sipeed.com/zh/api_reference/Maix/fpioa.html
https://cn.maixpy.sipeed.com/zh/api_reference/Maix/gpio.html
(One)
Open MaixPy IDE
create a new file
Save it under the name _1led.py
If you want an electric light, you need to know where the LED light is and open the schematic diagram of your own board.
My side is the WIDORA V3 development board, I use IO17 and 18, and the high level is on and the low level is off.
To use GPIO and GPIOA
Get the code in first
from Maix import FPIOA
from Maix import GPIO
To configure IO17 and IO18, first look at the function of FPIOA
So we also refer to the above (according to mine, his fm is not imported, you will get an error if you use it directly)
Bind IO17 to GPIOHS0, and similarly bind IO18 to HS1
fpioa = FPIOA()
fpioa.set_function(17,fpioa.GPIOHS0)
fpioa.set_function(18,fpioa.GPIOHS1)
Pin binding is complete, let’s start configuring GPIO output mode
The same, I copied a wave
led1 = GPIO(GPIO.GPIOHS0,GPIO.OUT)
led2 = GPIO(GPIO.GPIOHS1,GPIO.OUT)
Note that the GPIOHS0 binding is IO17 bound to the above set_function, so it does not mean IO0.
If you use set_function(0, gpioa.GPIOHS0), it is the IO0 bound to GPIOHS0
Then assign 0 or 1 to the LED
same
led1.value(1)
led2.value(1) //高电平
led1.value(0)//低电平
This will initialize the LED, just use it directly below
To use delay,
import utime
Then let him run in an endless loop, pay attention to the python syntax to backspace
The overall code is as follows
import utime
from Maix import FPIOA
from Maix import GPIO
fpioa = FPIOA()
fpioa.set_function(17,fpioa.GPIOHS0)
fpioa.set_function(18,fpioa.GPIOHS1)
led1 = GPIO(GPIO.GPIOHS0,GPIO.OUT)
led2 = GPIO(GPIO.GPIOHS1,GPIO.OUT)
while(1):
led1.value(1)
led2.value(0)
utime.sleep_ms(500)
led1.value(0)
led2.value(1)
utime.sleep_ms(500)
Open the zipper, select your K210 serial port, my side is COM4
After connecting to the development board, the zipper turns red, just press the green play button. At the same time, I suggest to switch to the serial terminal next door to see the information on the development board.
If you run according to my code and see two blue LED lights alternately, it proves that the light is successful
Note that this green run (play) only runs the current py code, if you want to burn it to the development board
Just save the script to Boot.py
Test after burning: click red to play and turn green, and red zipper to green,
Disconnect the USB of the development board, and then plug it in again. After that, you should be running the program to burn boot.py
After lighting up, see you in the next section