MicroPython Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

Let's have a look at how to connect the REPL and run the code:

  1. Open the computer's Terminal application.
  2. List device names before plugging in device by running ls /dev/ttyACM* on Linux or ls /dev/tty.* on macOS.
  3. Connect the board to your computer with a USB cable.
  4. List the device names again with the same command to discover the device name of the board.
  5. If the device name is /dev/ttyACM0, then the screen command would be screen /dev/ttyACM0 115200.
  6. Enter the command in the Terminal and start the Screen application.
  7. If Screen is able to connect successfully, the Python REPL should appear on the Terminal with output similar to the following text:
Adafruit CircuitPython 3.1.2 on 2019-01-07; Adafruit CircuitPlayground Express with samd21g18
>>>
  1. If the prompt doesn't appear, you can try pressing Ctrl + C and then press Enter, which will stop the currently running Python script and run the REPL with the following message:
Press any key to enter the REPL. Use CTRL-D to reload.
  1. Once the REPL prompt appears, we will have to test if the prompt is working by evaluating the 1+1 expression. It should produce the following output:
>>> 1+1
2