0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MicroPython のスクリプトを VScode で書き、mpremoteで実行する

Posted at

初めて tasks.jsonlaunch.json を書いてみた。
誤っていたらご容赦ください

Terminal で 準備

  • プロジェクトフォルダーを作る
  • プロジェクトフォルダーで .venv を構成
$ echo .venv >.gitignore
$ python3 -m venv .venv
$ . .venv/bin/activate.fish
(.venv) $ python -m pip install mpremote

VS Code で準備

Geminiに教えてもらいました...

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}
tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run on MicroPython",
            "type": "shell",
            "command": "./.venv/bin/mpremote",
            "args": ["run", "${file}"],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

実行

  • ローカル(PC側)でスクリプトを書く。
  • コマンドパレットで Tasks: Run Task を実行。またはメニューから Terminal - Run Task... を実行
  • Run on MicroPythonを選ぶと実行される。

おことわり...

VS Code側を簡素にするため、mpremote時のポート指定を省略しています。

see also

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?