8000 Update readme · arduino/micropython.js@45e28c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 45e28c2

Browse files
committed
Update readme
1 parent 728c2d8 commit 45e28c2

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,40 @@
22

33
This is an partial port of [pyboard.py](https://docs.micropython.org/en/latest/reference/pyboard.py.html) to javascript.
44

5+
## Basic usage
6+
7+
```
8+
const Board = require('micropython.js')
9+
// Instantiate board class
10+
const board = new Board()
11+
12+
// List available boards
13+
const ports = await board.listPorts()
14+
console.log('available boards', ports)
15+
16+
// Connect to a serial path
17+
await board.open('/dev/ttyUSB0')
18+
19+
// Enter raw repl, execute command, get output and leave raw repl
20+
await board.enter_raw_repl()
21+
const output = await board.exec_raw({ command: "print(123)" })
22+
await board.exit_raw_repl()
23+
24+
// List files on the board
25+
const rootFiles = await board.fs_ils()
26+
console.log('files at /', rootFiles)
27+
28+
// Close serial
29+
board.close()
30+
```
31+
532
## Examples
633

7-
1. Install dependencies `npm install`
8-
2. Navigate to example folder `cd examples`
9-
3. Execute files with `PORT` environment variable: `PORT=/dev/tty.SLAB_USBtoUART node 05_list_files.js`
34+
1. Navigate to example folder `cd examples`
35+
2. Execute files with `PORT` environment variable: `PORT=/dev/tty.SLAB_USBtoUART node 05_list_files.js`
1036

1137
## Command Line Interface (CLI)
1238

13-
1. Install dependencies `npm install`
1439
1. Run CLI `node cli.js [ARGUMENTS]...`
1540

1641
[Read more](CLI.md)
17-

0 commit comments

Comments
 (0)
0