Skip to content

Commit 4343fe4

Browse files
committed
REPL tutorial
1 parent 89d8e79 commit 4343fe4

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

00.Basics/REPL/REPL Notes.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
NOTES FOR REPL (READ EVAL PRINT LOOP)
2+
3+
- Easiest way to test code and run commands on the pyboard
4+
- Can be used in addition to the main.py script
5+
- Need to be connected to pyboard's USB serial (instructions below)
6+
7+
-----------------------------
8+
9+
Mac OS X
10+
11+
1. Open Terminal
12+
2. Type in the following and hit enter:
13+
screen /dev/tty.usbmodem*
14+
15+
-----------------------------
16+
17+
Windows:
18+
19+
1. Make sure the pyboard driver('pybcdc.inf' which is visible in the same directory as 'main.py' and 'boot.py') is installed.
20+
2. Access the Device Manager (Start > Control Panel > Device Manager) and click on 'Ports' to check the port to which the pyboard is connected (eg. COM8).
21+
3. Install PuTTY < http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html >
22+
4. Run putty.exe
23+
5. In the PuTTY Configuration window, click on 'Session' on the left pane.
24+
6. Under 'Connection type', select 'Serial'
25+
7. Change the 'Serial line' field to the port on which your pyboard is connected (eg. COM8)
26+
8. Change 'Speed' to 115200
27+
9. Click Open
28+
29+
-----------------------------
30+
31+
Linux:
32+
1. Open any terminal
33+
2. Type in the following and hit enter:
34+
screen /dev/ttyACM0
35+
3. You may have to replace ACM0 with ACM1 or a higher number and may have to prefix sudo to the command
36+
37+
-----------------------------
38+
39+
Now that the serial program is running hit enter and the prompt i.e. >>> will appear
40+
41+
Type in the following and hit enter:
42+
43+
pyb.LED.toggle(4)
44+
45+
The blue led on the board should toggle its state (if on, goes off and vice versa)
46+
On most terminals the upward arrow key is a shortcut to go to the last used command. Hit it and pyb.LED.toggle(4) should re-appear. If not just type it out. Hit enter.
47+
The state of the blue LED on the pyboard (LED 4) toggles its state each time the command is called.
48+
49+
50+
FOOTNOTE: added a boot.py that imports pyb and an empty main.py
51+
If pyb is not imported it will obviously need to be imported while playing with REPL.

00.Basics/REPL/boot.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# boot.py -- run on boot-up
2+
# can run arbitrary Python, but best to keep it minimal
3+
4+
import pyb

00.Basics/REPL/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# your main code goes here

0 commit comments

Comments
 (0)