TPYBoard Get MicroPython Tips

REPL (Interactive Interpreter?) The full name is Read Evaluate Print Loop, tpyboard allows users to interact with MicorPython. Using the REPL is the easiest way to test code and run instructions. Use the REPL to
add script content to main.py.
Using the REPL requires a USB serial connection to the tpyboard. How to do this depends on the development environment.
1. Windows needs to install the tpyboard
driver when using the USB serial port driver. The driver is in the USB flash drive of the tpyboard, named pybcdc.inf. To install the driver, the user needs to find the tpyboard device in the device manager list of the computer (devices that are not yet working, there should be a yellow warning icon next to them), right-click on the device, select tools (properties) and install the driver. The user needs to manually select the option to find the driver (not through the Windows auto-upgrade method) and install it. After the installation is complete, go back to the device manager to find the installed tpyboard and check which port (eg COM4) it uses. More information can be found in the document Guide for tpyboard on Windows (PDF). If there is any problem with the driver installation, please check it in time.
At this point you need to run a terminal program. Users can use the Hyper Terminal tool, or download the free program PuTTY: putty.exe. The serial program runs through the COM port found in the previous step. For PuTTY, click "Session" on the left interface, click the "Serial" button on the right, then select the COM port (eg COM4) in the serial port row, and finally, click the "Open" button.
2.Mac OSX
open terminal and run:
screen /dev/tty.usbmodem*
When you want to terminate the exit interface, use the shortcut key CTPL-A CTRL-\
3.Linux
to open the terminal and run:
screen /dev/ttyACM0
You can also try the connection method of piocom or minicom instead of the terminal interface. Users need to use /dev/ttyACM1 or higher ttyACM number. Also, users need to give themselves the correct permissions to connect to the device (eg group uucp or dialout, or permissions sudo).
4. Using the Interactive Selector It is
now possible to run MicroPython code directly on the tpyboard.
Open a serial program (such as Putty, terminal interface, piocom, etc.) to see an empty screen with a blinking cursor. Press any key to enter the MicroPython interpreter, displayed as >>>. You can confirm whether to enter through the following procedures:

print("hello tpyboard!")
hello tpyboard!
The user does not need to type the >>> character in the above routine, but should write something in the interpreter. At the end, once the print("hello world!") text is entered and the enter key is pressed, the output will be rendered on the screen as above.
If you are familiar with the python language, you can try writing different instructions. If the printing is unsuccessful, try the hardware reset or software reset method below. You can continue to enter other commands such as:
pyb.LED(1).on()
pyb.LED(2).on()
1 + 2
3
1 / 2
0.5
20 * 'py'
'pypypypypypypypypypypypypypypypypypy'
5. Reset the
error There are two ways to reset the development board. One is to type CTRL-D in the MicroPython interpreter to perform a software reset. The message that appears is as follows:

PYB: sync filesystems
PYB: soft reboot
Micro Python v1.0 on 2014-05-03; PYBv1.0 with STM32F405RG
Type “help()” for more information.

If it doesn't work, you can reset the hardware by pressing the RTS button (the black button under the USB cable on the development board). This will disconnect any ports from the tpyboard
If you are going to do a hardware reset, it is strongly recommended to close the serial port program and exit/uninstall the tpyboard device.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325518459&siteId=291194637
Recommended