# UnitV Maixpy Quick Start
## EasyLoader
### Kflash
> 3. For users who are used to command line operation, [can also choose Kflash as the firmware burning tool.](https://github.com/kendryte/kflash.py)
### Serial-Tool
>1. You will need a serial debugging tool for programming M5StickV, you can use Putty [in here](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html),for download and information.
>2. Run Putty, connect M5StickV to your PC, in Putty, set com number, baudrate, click "open", by now the connect process should started.(you can check the com number in device manager on your PC)
> When connected, it will automatically enter Maixpy UI. Now the device is runing the default code, you can terminate it by "Ctrl+C".
## Edit and Run the Code
### Editting
> The language shell programm(REPL) is good for instant code validatation, it can be used at short code programming and validation. In real project where we will have massive amount of code, in that case we will need a Code Editor for better orgnization of the code files.
>Inside MaixPy,integrates a open source Editor [Micropython Editor(pye)](https://github.com/robert-hh/Micropython-Editor),which is convenient for us to manage the code.
function `os.listdir()` is for checking the files in current directory.
With function `pye("hello.py")`, you can create new files and enter editing mode(if file exist, only enter editting mode)[click for more](https://github.com/robert-hh/Micropython-Editor/blob/master/Pyboard%20Editor.pdf)
If editing finished, you can do `Ctrl+S` > `Enter` to save the script. `Ctrl+Q` to exit edit mode.
**Notice**: This editor have some requiremnt on the Serial tool, KEY `BackSpace` have to set as `DEL` function,or `BackSpace` will implement the same function as `Ctrl+H`(charater replacement)
### File Execution
Function `os.chdir()` is used for switch current directory to a certain directory, for example `os.chdir("/flash")`
#### Solution 1: `import`
Run `import hello`
You can see the output: `hello maixpy`
In this way, it is simple and handy, but thers something worth your attention, `import` can only be utilized once, the second time `import` won't work. If you need to use `import` mutiple times, please refers to solution 2 below
#### Solution 2: `exec()`
Use `exec()` function:
```clike
with open("hello.py") as f:
exec(f.read())
```
### AutoRun after Power On
System will create a `boot.py` file at directory `/flash` or `/sd` , it will run this script after power on, modify this file will realize the AutoRun.
## MaixPy IDE
#### Download MaixPy IDE
MaixPy IDE can easily realize real-time editing, uploading, execution, and real-time monitoring of camera images, file transfer and other functions. Using MaixPy IDE, because data compression and transmission require a part of resources, performance will be reduced, but This is a great development tool for developers who are not demanding in performance or who are in the debugging phase.
>Click the Connect button in the lower left corner and select the correct connection port, click OK.
>When the connection button changes from green to red, it has been connected successfully. You can edit the code in the edit box above. Click the Run button in the lower left corner to execute the code and verify it.
## WS2812
The firmware has a built-in WS2812 RGB LED driver library. The following is a reference routine. Note: Since the expansion port of UnitV does not have a driving load function, this program is only suitable for driving the built-in RGB LED:
```clike
from modules import ws2812
from fpioa_manager import *
fm.register(8)
class_ws2812 = ws2812(8,100)
r=0
dir = True
while True:
if dir:
r += 5
else:
r -= 5
if r>=255:
r = 255
dir = False
elif r<0:
r = 0
dir = True
for i in range(100):
a = class_ws2812.set_led(i,(0,0,r))
a=class_ws2812.display()
```
## Library
In the library documentation, you can find more APIs to help you build a variety of applications。