We take blink and breathing light as examples to learn the use of micropython on ameba. However, currently ameba doesn’t support Timer, and there is no breathing light demo.

Blink Program

   from machine import Pin
   import time
   led = Pin('PC_1',Pin.OUT)
   while True:
    led.value(1)
    time.sleep(0.5)
    led.value(0)
    time.sleep(0.5)


Using micropython on ameba for the first time, we must burn micropython onto ameba board. The burning method is very simple. Download the following link and then unpack it. We will get a ram_all.bin file (if there is problem of unpacking under windows, think about unpacking under linux or virtual machine). Burn the file onto ameba board, and then we can use micropython on ameba. Of course we need a terminal (putty) to write micropython
Link: https://github.com/cwyark/micropython/releases/download/v1.8.3/ram_all.tar

After ameba is linked to PC, we need to install a driver. At the completion of installation, we can see MBED (a mobile device) in my computer. https://developer.mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe.


Then right-click->my computer->management->device manager->port. We can see the port number of ameba. Here you can see my port no. is COM7.
烧录方法:
Burning method:



After completing driver installation, you can see a mobile device MBED in my computer. Double click to open it. Copy the unpacked ram_all.bin file to MBED. Meanwhile you can see that the green light is flashing, which reflects burning. When it stops flashing, burning is completed.

After finishing preparation, open putty terminal. The following interface will appear. Follow the arrow to modify selection.

After finishing preparation, open putty terminal. The following interface will appear. Follow the arrow to modify selection.

These are default selection of 115200 8 1 None None.

After finishing setting, click open. Then click enter key several times. There will be an interface as follows.

Press Ctrl+E in the terminal. There will be a paste command line as follows

Copy the blink program and then right-click in the terminal to finish the copy as shown below. Press Ctrl+D for completing copy. Press Ctrl+C to cancel copy.

It is very simple. Led light is flashing. Press Ctrl+C for exit after completion (currently, ameba doesn’t support the command).

Use of micropython on esp32

esp32

Temporarily, esp32 doesn’t support Timer, therefore there is no breathing light demo.


Blink Program

from machine import Pin
   import time
   led = Pin(13,Pin.OUT)
   try:
     whileTrue:
       led.value(1)
       time.sleep(0.5)
       led.value(0)
       time.sleep(0.5)
   except:
     led.value(0)

Method for burning micropython firmware


Use the official programming tools to burn. Before burning, we need to compile micropython firmware first. Refer to the official compiling method. You can directly use my compiled firware: micropython firmware to save the trouble. Note that flash initial address of each firmware cannot be changed. Address of official firmware compiling method is:
https://github.com/micropython/micropython-esp32/tree/esp32/esp32


After downloading the official burning tool, double click the burning tool, as shown below:

There will be two interfaces after opening:

Click ESP32DownloadTool on the right interface. We can see the interface of burning firmware. Now we are not far from success. Keep going! At this time, import the three compiled or downloaded bin files of micropython into burning tool. Check the port no. in my computer. Right-click->my computer->management->device manager->port. Note: be sure the address is right, otherwise burning may not be successful or it cannot work normally after burning.

After burning, close burning tool. Open and operate terminal putty of micropython. Select port No. (COM12), connection type(Serial).

Other settings are as follows. Click Open after setting.

Press enter key several times after Open. We can enter micropython language at putty terminal.

Press Ctrl+E to enter paste mode. Right-click in the mode to paste...

Read more »