├── .github
└── FUNDING.yml
├── .gitignore
├── .vscode
└── settings.json
├── AUTHORS.md
├── CONTRIBUTING.md
├── LICENSE
├── README.rst
├── sets
├── boost
│ ├── creative-toolbox
│ │ ├── auto-builder
│ │ │ ├── auto-builder.jpg
│ │ │ ├── index.md
│ │ │ └── main.py
│ │ ├── creative-toolbox.jpg
│ │ └── index.md
│ ├── droid-commander
│ │ ├── droid-commander.jpg
│ │ ├── index.md
│ │ └── r2-d2
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ └── r2-d2.jpg
│ └── index.md
├── city
│ ├── 60198-cargo-train
│ │ ├── 60198-cargo-train.jpg
│ │ ├── index.md
│ │ ├── slope-detection
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ ├── sensor-placement.jpg
│ │ │ └── slope-detection.jpg
│ │ └── speed-control
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ └── train-load.jpg
│ └── index.md
├── mindstorms-ev3
│ ├── education-core
│ │ ├── color_sorter
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ ├── gyro_boy
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ ├── puppy
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ ├── robot_arm
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ ├── robot_educator_basic
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ ├── robot_educator_line
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ ├── robot_educator_ultrasonic
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ └── sets_ev3_education_core.code-workspace
│ ├── education-expansion
│ │ ├── elephant
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ ├── sets_ev3_education_expansion.code-workspace
│ │ ├── stair_climber
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ ├── tank_bot
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ └── main.py
│ │ └── znap
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ ├── extensions.json
│ │ │ ├── launch.json
│ │ │ └── settings.json
│ │ │ └── main.py
│ ├── home-bonus
│ │ ├── bobb3e
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── bobb3e.jpeg
│ │ │ ├── bobb3e.py
│ │ │ ├── index.md
│ │ │ └── main.py
│ │ ├── dinor3x
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── dinor3x.jpeg
│ │ │ ├── dinor3x.py
│ │ │ ├── index.md
│ │ │ └── main.py
│ │ ├── el3ctric-guitar
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── el3ctric-guitar.jpeg
│ │ │ ├── el3ctric_guitar.py
│ │ │ ├── index.md
│ │ │ └── main.py
│ │ ├── ev3-d4
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── ev3-d4.png
│ │ │ ├── ev3_d4.py
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ └── rc_tank_util.py
│ │ ├── ev3-game
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── ev3-game.jpeg
│ │ │ ├── ev3_game.py
│ │ │ ├── index.md
│ │ │ └── main.py
│ │ ├── index.md
│ │ ├── kraz3
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── README.md
│ │ │ ├── index.md
│ │ │ ├── kraz3.jpeg
│ │ │ ├── kraz3.py
│ │ │ ├── main.py
│ │ │ └── rc_tank_util.py
│ │ ├── mr-b3am
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ ├── mr-b3am.png
│ │ │ └── mr_b3am.py
│ │ ├── rac3-truck
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ ├── rac3-truck.jpeg
│ │ │ └── rac3_truck.py
│ │ ├── robodoz3r
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── README.md
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ ├── rc_tank_util.py
│ │ │ ├── robodoz3r.jpeg
│ │ │ └── robodoz3r.py
│ │ ├── sets-mindstorms-ev3-home-bonus.code-workspace
│ │ └── wack3m
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ ├── extensions.json
│ │ │ ├── launch.json
│ │ │ └── settings.json
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ ├── wack3m.jpg
│ │ │ └── wack3m.py
│ ├── home-main
│ │ ├── ev3rstorm
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── ev3rstorm.jpeg
│ │ │ ├── ev3rstorm.py
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ └── rc_tank_util.py
│ │ ├── gripp3r
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── gripp3r.jpeg
│ │ │ ├── gripp3r.py
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ └── rc_tank_util.py
│ │ ├── index.md
│ │ ├── mindstorms-ev3-home.jpg
│ │ ├── r3ptar
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── index.md
│ │ │ ├── main.py
│ │ │ ├── r3ptar.jpeg
│ │ │ └── r3ptar.py
│ │ ├── sets_ev3_home.code-workspace
│ │ ├── spik3r
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ │ ├── extensions.json
│ │ │ │ ├── launch.json
│ │ │ │ └── settings.json
│ │ │ ├── README.md
│ │ │ ├── main.py
│ │ │ ├── spik3r.jpeg
│ │ │ └── spik3r.py
│ │ └── track3r
│ │ │ ├── .gitignore
│ │ │ ├── .vscode
│ │ │ ├── extensions.json
│ │ │ ├── launch.json
│ │ │ └── settings.json
│ │ │ ├── index.md
│ │ │ ├── rc_tank_util.py
│ │ │ ├── track3r.jpeg
│ │ │ ├── track3r_base.py
│ │ │ ├── track3r_with_biblade_spinner.py
│ │ │ ├── track3r_with_blasting_bazooka.py
│ │ │ ├── track3r_with_gripping_claw.py
│ │ │ └── track3r_with_heavy_hammer.py
│ └── index.md
├── mindstorms-robot-inventor
│ ├── fan-inventions
│ │ ├── exploration-rover
│ │ │ ├── exploration-rover.jpg
│ │ │ ├── exploration-rover.pdf
│ │ │ ├── index.md
│ │ │ └── main.py
│ │ └── index.md
│ ├── index.md
│ ├── main-models
│ │ ├── .gitignore
│ │ ├── blast
│ │ │ ├── blast-basic.py
│ │ │ ├── blast.jpeg
│ │ │ └── index.md
│ │ ├── gelo
│ │ │ ├── basic.md
│ │ │ ├── gelo-bone.png
│ │ │ ├── gelo.jpg
│ │ │ ├── gelo.py
│ │ │ ├── gelo_basic.py
│ │ │ ├── gelo_remote.py
│ │ │ ├── gelo_repl.py
│ │ │ ├── gelo_roam.py
│ │ │ ├── gelo_template.py
│ │ │ ├── gelo_tricks.py
│ │ │ ├── index.md
│ │ │ ├── remote.md
│ │ │ ├── remote.png
│ │ │ ├── repl.md
│ │ │ ├── roam.md
│ │ │ ├── template.md
│ │ │ └── tricks.md
│ │ ├── index.md
│ │ ├── mvp
│ │ │ ├── index.md
│ │ │ ├── mvp-basic.py
│ │ │ └── mvp.jpeg
│ │ ├── robot-inventor.jpg
│ │ └── tricky
│ │ │ ├── index.md
│ │ │ ├── tricky-basic.py
│ │ │ ├── tricky-playing-soccer.py
│ │ │ └── tricky.jpeg
│ └── other-models
│ │ ├── balancer
│ │ ├── README.md
│ │ └── main.py
│ │ ├── block-flipper
│ │ ├── block-flipper.JPG
│ │ ├── block-flipper.py
│ │ └── index.md
│ │ ├── index.md
│ │ ├── mini-loader
│ │ ├── index.md
│ │ ├── mini-loader.JPG
│ │ └── miniLoader_RC.py
│ │ ├── quick-reference
│ │ ├── Quick_Ref.JPG
│ │ ├── Quick_Ref.py
│ │ └── index.md
│ │ └── steerbot
│ │ ├── index.md
│ │ ├── main.py
│ │ ├── steerbot-instructions.pdf
│ │ └── steerbot.jpg
├── spike-prime
│ ├── core-set
│ │ ├── cnc_machine
│ │ │ ├── README.md
│ │ │ └── basic_cnc_machine.py
│ │ ├── hand-controlled-grabber
│ │ │ ├── hand-controlled-grabber.png
│ │ │ ├── index.md
│ │ │ └── main.py
│ │ ├── index.md
│ │ ├── kiki_dog
│ │ │ ├── README.md
│ │ │ └── kiki_seeing_colors.py
│ │ └── spike-prime-core.jpg
│ └── index.md
└── technic
│ ├── 42099-off-roader
│ ├── 42099-off-roader.jpg
│ ├── driving
│ │ ├── index.md
│ │ ├── main.py
│ │ └── truck.jpg
│ ├── index.md
│ ├── keyboard-remote
│ │ ├── index.md
│ │ ├── keyboard-remote-truck.jpg
│ │ ├── main.py
│ │ ├── remote.py
│ │ └── terminalwindow.png
│ ├── obstacle-avoidance
│ │ ├── index.md
│ │ ├── main.py
│ │ └── obstacle-avoidance.jpg
│ └── powered-up-remote
│ │ ├── index.md
│ │ ├── main.py
│ │ ├── off-roader-blocks-screenshot.png
│ │ └── powered-up-remote-truck.jpg
│ ├── 42109_top_gear_rally_car
│ └── keyboard_remote
│ │ ├── README.md
│ │ └── main.py
│ ├── 42114-volvo-articulated-hauler
│ ├── 42114-volvo-articulated-hauler.jpg
│ ├── index.md
│ └── powered-up-remote
│ │ ├── 42114_88010.jpg
│ │ ├── index.md
│ │ ├── main.py
│ │ └── remote_description.png
│ ├── 42124-off-road-buggy
│ ├── 42124-off-road-buggy.jpg
│ ├── index.md
│ └── powered-up-remote
│ │ ├── index.md
│ │ ├── main.py
│ │ └── powered-up-remote-buggy.jpg
│ ├── 42129-mercedes-benz-zetros
│ ├── 42129-mercedes-benz-zetros.jpg
│ ├── index.md
│ └── powered-up-remote
│ │ ├── index.md
│ │ ├── main.py
│ │ └── powered-up-remote-lock.jpg
│ ├── 42131-cat-bulldozer
│ ├── 42131-cat-bulldozer.jpg
│ ├── index.md
│ └── powered-up-remote
│ │ ├── 42131-cat-bulldozer-remote.jpg
│ │ ├── index.md
│ │ └── main.py
│ ├── 42140-app-controlled-transformation-vehicle
│ ├── 42140-app-controlled-transformation-vehicle.jpg
│ ├── index.md
│ └── powered-up-remote
│ │ ├── index.md
│ │ ├── main.py
│ │ ├── main2.py
│ │ └── transformation-vehicle-remote.jpg
│ ├── 42160-audi-rs-q-e-tron
│ ├── 42160-audi-rs-q-e-tron.webp
│ ├── index.md
│ ├── powered-up-remote
│ │ ├── e-tron-remote.jpg
│ │ ├── index.md
│ │ └── main.py
│ └── xbox-controller
│ │ ├── audi-xbox-program.png
│ │ ├── audi-xbox.jpg
│ │ ├── audi_blocks.py
│ │ ├── audi_python.py
│ │ └── index.md
│ └── index.md
├── setup.cfg
├── tutorials
├── dev
│ ├── dev.png
│ ├── index.md
│ └── tools
│ │ ├── index.md
│ │ ├── linux
│ │ ├── index.md
│ │ └── pybricks-code-linux.png
│ │ └── vscode
│ │ ├── index.md
│ │ └── pybricks-vscode.png
├── remix
│ ├── index.md
│ └── iot
│ │ ├── index.md
│ │ └── iot.png
└── wireless
│ ├── hub-to-device
│ ├── drawing.svg
│ ├── hub-to-device.png
│ ├── hub-to-phone.png
│ ├── index.md
│ ├── pc-communication
│ │ ├── demo.py
│ │ ├── hub-to-pc.png
│ │ ├── index.md
│ │ └── main.py
│ ├── pc-keyboard
│ │ ├── hub-keyboard.png
│ │ ├── index.md
│ │ ├── remote.py
│ │ └── terminalwindow.png
│ └── wireless.png
│ ├── hub-to-hub
│ ├── broadcast
│ │ ├── index.md
│ │ ├── remote.py
│ │ └── vehicle.py
│ ├── hub-to-hub.png
│ ├── index.md
│ └── pybricks-to-official-fw
│ │ ├── duplo-spike-small.jpg
│ │ ├── duplo.py
│ │ ├── duplotrain.mpd
│ │ ├── index.md
│ │ ├── instructions.pdf
│ │ └── train_driver.py
│ ├── index.md
│ └── remote-control
│ ├── button-basics
│ ├── RC_Tutorial.py
│ └── index.md
│ ├── drive-base
│ ├── RC_DriveBase.py
│ ├── drive-base.JPG
│ └── index.md
│ ├── index.md
│ └── lego-remote.jpg
└── update_workspaces.py
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [pybricks]
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 | MANIFEST
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 | .pytest_cache/
49 |
50 | # Translations
51 | *.mo
52 | *.pot
53 |
54 | # Django stuff:
55 | *.log
56 | local_settings.py
57 | db.sqlite3
58 |
59 | # Flask stuff:
60 | instance/
61 | .webassets-cache
62 |
63 | # Scrapy stuff:
64 | .scrapy
65 |
66 | # Sphinx documentation
67 | docs/_build/
68 |
69 | # PyBuilder
70 | target/
71 |
72 | # Jupyter Notebook
73 | .ipynb_checkpoints
74 |
75 | # pyenv
76 | .python-version
77 |
78 | # celery beat schedule file
79 | celerybeat-schedule
80 |
81 | # SageMath parsed files
82 | *.sage.py
83 |
84 | # Environments
85 | .env
86 | .venv
87 | env/
88 | venv/
89 | ENV/
90 | env.bak/
91 | venv.bak/
92 |
93 | # Spyder project settings
94 | .spyderproject
95 | .spyproject
96 |
97 | # Rope project settings
98 | .ropeproject
99 |
100 | # mkdocs documentation
101 | /site
102 |
103 | # mypy
104 | .mypy_cache/
105 |
106 | # LDRAW
107 | LPub3D
108 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.rulers": [70],
3 |
4 | "python.linting.enabled": true,
5 | "python.linting.pylintEnabled": true,
6 | "python.linting.flake8Enabled": true,
7 | "python.linting.mypyEnabled": true,
8 | "python.linting.pydocstyleEnabled": false,
9 | "python.linting.pycodestyleEnabled": true,
10 | "python.linting.prospectorEnabled": true,
11 | "python.linting.pylamaEnabled": true,
12 | "python.linting.banditEnabled": true
13 | }
14 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 | **Project:** `pybricks-api`
2 |
3 | **The Pybricks Authors (copyright holders of this project):**
4 | - Laurens Valk
5 | - David Lechner
6 | - LEGO System A/S
7 |
8 | **Maintainers:**
9 | - Laurens Valk (@laurensvalk)
10 | - David Lechner (@dlech)
11 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | This repository is a submodule of the [pybricks-api][api] repository. Any
2 | changes made to `pybricks-projects` will also affect the documentation generated
3 | by `pybricks-api`. Please follow the link for guidelines on [contributing to
4 | pybricks-api][contrib].
5 |
6 |
7 | [api]: https://github.com/pybricks/pybricks-api
8 | [contrib]: https://github.com/pybricks/pybricks-api/blob/master/CONTRIBUTING.md
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-2023 The Pybricks Authors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | Pybricks Projects
2 | -----------------
3 | This repository contains example programs for official and unofficial LEGO
4 | models, made using `Pybricks MicroPython`_
5 |
6 | For suggestions and troubleshooting, please create an issue on our
7 | `support issue tracker`_.
8 |
9 | .. _Pybricks MicroPython: https://pybricks.com/
10 | .. _support issue tracker: https://github.com/pybricks/support/issues
11 |
--------------------------------------------------------------------------------
/sets/boost/creative-toolbox/auto-builder/auto-builder.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/boost/creative-toolbox/auto-builder/auto-builder.jpg
--------------------------------------------------------------------------------
/sets/boost/creative-toolbox/auto-builder/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Precision building with Auto Builder"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "auto-builder.jpg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "TXvCEK1MNGQ"
11 | description:
12 | "The Auto Builder builds LEGO figures autonomously. These Python scripts
13 | make it work smoothly and accurately."
14 | building_instructions:
15 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/17101_A_AutoBuilder.pdf
16 | code: "#coding-instructions"
17 | ---
18 |
19 | # Coding instructions
20 |
21 | This program resets the motors to known positions, and then constructs the
22 | LEGO figure brick-by-brick.
23 |
24 | This works by repeatedly:
25 | - moving the belt motor to the given brick;
26 | - picking the brick up by moving the arm down and up;
27 | - moving the belt back to the base position;
28 | - putting the brick down.
29 |
30 | The brick positions are given as the degrees the belt motor turns relative to
31 | the base position. You can tweak these values by a few degrees if needed.
32 |
33 | {% include copy-code.html %}
34 | ```python
35 | {% include_relative main.py %}
36 | ```
37 |
38 |
39 | # Further exploration
40 |
41 | The provided program is very basic, demonstrating only the core principles.
42 | Here's a few ideas and challenges for further exploration:
43 | - Change the order of the bricks in the `for`-loop to build something else.
44 | - Instead of pushing the element down for two seconds, you could stop sooner.
45 | Try experimenting with the [run_until_stalled](https://docs.pybricks.com/en/latest/pupdevices/motor.html#pybricks.pupdevices.Motor.run_until_stalled)
46 | method. This can speed up the build process.
47 | - Speaking of increasing speed, how fast can you make it? Optimize this robot
48 | and set a new world record!
49 |
--------------------------------------------------------------------------------
/sets/boost/creative-toolbox/auto-builder/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import MoveHub
2 | from pybricks.pupdevices import Motor
3 | from pybricks.parameters import Port, Stop, Color
4 | from pybricks.tools import wait
5 |
6 | # Initialize the arm motor
7 | arm = Motor(Port.D)
8 | arm.run_until_stalled(-100, duty_limit=30)
9 | arm.reset_angle(0)
10 |
11 | # Initialize the belt motor
12 | belt = Motor(Port.B)
13 | belt.run_until_stalled(-100, duty_limit=30)
14 | belt.reset_angle(0)
15 |
16 | # Component positions
17 | FEET = 0
18 | BELLY = 365
19 | HEAD = 128
20 | ARMS = 244
21 | NECK = 521
22 | BASE = 697
23 |
24 | # Place all the elements
25 | for element in (FEET, BELLY, ARMS, NECK, HEAD):
26 |
27 | # Go to the element
28 | belt.run_target(speed=200, target_angle=element)
29 |
30 | # Grab the element
31 | arm.run_time(speed=300, time=2000)
32 |
33 | # Lift the element by going back to nearly zero
34 | arm.run_target(speed=300, target_angle=55)
35 |
36 | # Go to the base
37 | belt.run_target(speed=200, target_angle=BASE)
38 | wait(500)
39 |
40 | # Put the element down
41 | arm.run_time(speed=300, time=2000)
42 |
43 | # Lift the arm back up
44 | arm.run_target(speed=300, target_angle=0)
45 |
46 | # When we are done, eject the result
47 | belt.run_target(speed=200, target_angle=FEET)
48 |
--------------------------------------------------------------------------------
/sets/boost/creative-toolbox/creative-toolbox.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/boost/creative-toolbox/creative-toolbox.jpg
--------------------------------------------------------------------------------
/sets/boost/creative-toolbox/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Creative Toolbox
3 | number: 17101
4 | image:
5 | local: "creative-toolbox.jpg"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Add set description"
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/boost/droid-commander/droid-commander.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/boost/droid-commander/droid-commander.jpg
--------------------------------------------------------------------------------
/sets/boost/droid-commander/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Star Wars™ Droid Commander"
3 | number: 75253
4 | image:
5 | local: "droid-commander.jpg"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Add set description"
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/boost/droid-commander/r2-d2/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Driving and turning with R2-D2"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "r2-d2.jpg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "aDA_RQq4t3k"
11 | description:
12 | "Fan-favorite droid R2-D2 is now Python-powered with Pybricks."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/75253_X_Artoo.pdf
15 | code: "#code"
16 | ---
17 |
18 | # Code
19 |
20 | This is an example program to help you get R2-D2 moving. If you are just getting
21 | started with coding, you don't need to understand all of it. Just scroll down
22 | to the `MAIN PROGRAM` section and start there.
23 |
24 | {% include copy-code.html %}
25 | ```python
26 | {% include_relative main.py %}
27 | ```
28 |
29 |
30 | # Further exploration
31 |
32 | Here's a few ideas and challenges for further exploration:
33 |
34 | - Modify the main program to call `stare_and_turn(360 * 2)` to see R2-D2 turn
35 | his body without turning his head.
36 | - Write your own function to combine a sequence of actions. Then use it as
37 | part of a more complex program.
38 |
39 | ```python
40 | def my_function():
41 | # Write your commands here!
42 | ```
43 |
44 | - Create an obstacle course for R2-D2 and write a program to navigate safely
45 | around the obstructions.
46 |
--------------------------------------------------------------------------------
/sets/boost/droid-commander/r2-d2/r2-d2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/boost/droid-commander/r2-d2/r2-d2.jpg
--------------------------------------------------------------------------------
/sets/boost/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "BOOST"
3 | layout: theme
4 | description: "Theme description"
5 | ---
6 |
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/60198-cargo-train.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/city/60198-cargo-train/60198-cargo-train.jpg
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Cargo Train"
3 | number: 60198
4 | image:
5 | local: "60198-cargo-train.jpg"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Python projects that apply to most modern LEGO trains."
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/slope-detection/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Train slope detection"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "slope-detection.jpg"
8 | video:
9 | youtube: "Wc0mRIBjhIU"
10 | description:
11 | "Detect the slope of the track. This lets you determine where the train
12 | is on the circuit."
13 | building_instructions:
14 | external:
15 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245902.pdf
16 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245905.pdf
17 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245917.pdf
18 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245924.pdf
19 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245926.pdf
20 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245931.pdf
21 | code: "#program"
22 |
23 | ---
24 |
25 | ## Design modifications
26 | Build the train using the standard instructions. Mount the
27 | [tilt sensor][tiltsensor]
28 | horizontally in the train, with the cable side facing towards direction of
29 | driving:
30 |
31 | 
32 |
33 | Connect the motor to port A and connect the tilt sensor to port B.
34 |
35 | ## Program
36 |
37 | This program makes the train drive until it detects a slope of 8 degrees or
38 | more. Then it drives back down.
39 |
40 | {% include copy-code.html %}
41 | ```python
42 | {% include_relative main.py %}
43 | ```
44 |
45 | ## Programming and running instructions
46 | The train must start on a horizontal track. Then run the program.
47 |
48 | [tiltsensor]: https://docs.pybricks.com/en/latest/pupdevices/tiltsensor.html
49 |
50 |
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/slope-detection/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import TiltSensor, DCMotor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Initialize the train motor.
6 | # If you have a motor with encoders, use the Motor class instead.
7 | train = DCMotor(Port.A)
8 |
9 | # Initialize the tilt sensor.
10 | sensor = TiltSensor(Port.B)
11 |
12 | # Measure the tilt while the train is on a flat surface.
13 | pitch_start, roll_start = sensor.tilt()
14 |
15 | # Start driving.
16 | train.dc(-50)
17 |
18 | # We need to reach a constant speed before we can check tilt again,
19 | # because acceleration affects tilt. So we wait a second.
20 | wait(1000)
21 |
22 | # Wait for the train to sense the hill.
23 | while True:
24 | pitch_now, roll_now = sensor.tilt()
25 |
26 | wait(10)
27 |
28 | # If we reached an extra 3 degrees, exit/break the loop.
29 | if pitch_now >= pitch_start + 8:
30 | break
31 |
32 | # Drive backwards for a few seconds and then stop.
33 | train.dc(40)
34 | wait(3000)
35 | train.dc(0)
36 |
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/slope-detection/sensor-placement.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/city/60198-cargo-train/slope-detection/sensor-placement.jpg
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/slope-detection/slope-detection.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/city/60198-cargo-train/slope-detection/slope-detection.jpg
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/speed-control/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Train speed control"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "train-load.jpg"
8 | video:
9 | youtube: "Qc7sIkzEgIc"
10 | description:
11 | "Make a train drive at a constant speed, independent of load and battery
12 | level."
13 | building_instructions:
14 | external:
15 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245902.pdf
16 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245905.pdf
17 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245917.pdf
18 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245924.pdf
19 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245926.pdf
20 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6245931.pdf
21 | code: "#program"
22 |
23 | ---
24 |
25 | ## Design modifications
26 | Build any train using the standard instructions. Mount the
27 | [color distance sensor][colordistancesensor] in the frame, as shown in the
28 | video. Connect the motor to port A and connect the sensor to port B.
29 |
30 | ## Program
31 |
32 | This program makes the train drive at a constant speed. It works by counting
33 | the tracks using the Color and Distance Sensor. The motor "power" is
34 | automatically increased if the counted position is below the target position,
35 | and reduced if it is too far ahead. The target position steadily increases
36 | over time. This makes the train follow the target at the same speed.
37 |
38 | In this video, there's a white surface underneath the tracks. If your
39 | background is different, you can change the reflection values
40 | accordingly, as shown in the comments below. You could also adapt the script
41 | so it responds to different colors instead of reflected light intensity.
42 |
43 | {% include copy-code.html %}
44 | ```python
45 | {% include_relative main.py %}
46 | ```
47 |
48 | [colordistancesensor]: https://docs.pybricks.com/en/latest/pupdevices/colordistancesensor.html
49 |
50 |
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/speed-control/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import DCMotor, ColorDistanceSensor
2 | from pybricks.tools import StopWatch
3 | from pybricks.parameters import Port
4 |
5 | # Initialize the motor and the sensor.
6 | motor = DCMotor(Port.A)
7 | sensor = ColorDistanceSensor(Port.B)
8 |
9 | # These are the sensor reflection values in this setup.
10 | # Adapt them to match your ambient light conditions.
11 | LIGHT = 57
12 | DARK = 16
13 |
14 | # Threshold values. We add a bit of hysteresis to make
15 | # sure we skip extra changes on the edge of each track.
16 | hysteresis = (LIGHT - DARK) / 4
17 | threshold_up = (LIGHT + DARK) / 2 + hysteresis
18 | threshold_down = (LIGHT + DARK) / 2 - hysteresis
19 |
20 | # Initial position state.
21 | on_track = True
22 | position = 0
23 |
24 | # Desired drive speed in mm per second.
25 | SPEED = 300
26 |
27 | # It's two studs (16 mm) for each position increase.
28 | MM_PER_COUNT = 16
29 |
30 | # Start a timer.
31 | watch = StopWatch()
32 |
33 | while True:
34 |
35 | # Measure the reflection.
36 | reflection = sensor.reflection()
37 |
38 | # If the reflection exceeds the threshold, increment position.
39 | if (reflection > threshold_up and on_track) or (reflection < threshold_down and not on_track):
40 | on_track = not on_track
41 | position += 1
42 |
43 | # Compute the target position based on the time.
44 | target_count = watch.time() / 1000 * SPEED / MM_PER_COUNT
45 |
46 | # The duty cycle is the position error times a constant gain.
47 | duty = 2*(target_count - position)
48 |
49 | # Apply the duty cycle.
50 | motor.dc(duty)
51 |
--------------------------------------------------------------------------------
/sets/city/60198-cargo-train/speed-control/train-load.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/city/60198-cargo-train/speed-control/train-load.jpg
--------------------------------------------------------------------------------
/sets/city/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "City"
3 | layout: theme
4 | description: "Theme description"
5 | ---
6 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/color_sorter/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/color_sorter/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/color_sorter/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/color_sorter/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/gyro_boy/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/gyro_boy/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/gyro_boy/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/gyro_boy/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/puppy/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/puppy/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/puppy/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/puppy/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_arm/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_arm/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_arm/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_arm/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_basic/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_basic/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_basic/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_basic/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "python.languageServer": "None"
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_basic/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | """
4 | Example LEGO® MINDSTORMS® EV3 Robot Educator Driving Base Program
5 | -----------------------------------------------------------------
6 |
7 | This program requires LEGO® EV3 MicroPython v2.0.
8 | Download: https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3
9 |
10 | Building instructions can be found at:
11 | https://education.lego.com/en-us/support/mindstorms-ev3/building-instructions#robot
12 | """
13 |
14 | from pybricks.hubs import EV3Brick
15 | from pybricks.ev3devices import Motor
16 | from pybricks.parameters import Port
17 | from pybricks.robotics import DriveBase
18 |
19 | # Initialize the EV3 Brick.
20 | ev3 = EV3Brick()
21 |
22 | # Initialize the motors.
23 | left_motor = Motor(Port.B)
24 | right_motor = Motor(Port.C)
25 |
26 | # Initialize the drive base.
27 | robot = DriveBase(left_motor, right_motor, wheel_diameter=55.5, axle_track=104)
28 |
29 | # Go forward and backwards for one meter.
30 | robot.straight(1000)
31 | ev3.speaker.beep()
32 |
33 | robot.straight(-1000)
34 | ev3.speaker.beep()
35 |
36 | # Turn clockwise by 360 degrees and back again.
37 | robot.turn(360)
38 | ev3.speaker.beep()
39 |
40 | robot.turn(-360)
41 | ev3.speaker.beep()
42 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_line/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_line/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_line/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_line/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "python.languageServer": "None"
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_line/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 | """
4 | Example LEGO® MINDSTORMS® EV3 Robot Educator Color Sensor Down Program
5 | ----------------------------------------------------------------------
6 |
7 | This program requires LEGO® EV3 MicroPython v2.0.
8 | Download: https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3
9 |
10 | Building instructions can be found at:
11 | https://education.lego.com/en-us/support/mindstorms-ev3/building-instructions#robot
12 | """
13 |
14 | from pybricks.ev3devices import Motor, ColorSensor
15 | from pybricks.parameters import Port
16 | from pybricks.tools import wait
17 | from pybricks.robotics import DriveBase
18 |
19 | # Initialize the motors.
20 | left_motor = Motor(Port.B)
21 | right_motor = Motor(Port.C)
22 |
23 | # Initialize the color sensor.
24 | line_sensor = ColorSensor(Port.S3)
25 |
26 | # Initialize the drive base.
27 | robot = DriveBase(left_motor, right_motor, wheel_diameter=55.5, axle_track=104)
28 |
29 | # Calculate the light threshold. Choose values based on your measurements.
30 | BLACK = 9
31 | WHITE = 85
32 | threshold = (BLACK + WHITE) / 2
33 |
34 | # Set the drive speed at 100 millimeters per second.
35 | DRIVE_SPEED = 100
36 |
37 | # Set the gain of the proportional line controller. This means that for every
38 | # percentage point of light deviating from the threshold, we set the turn
39 | # rate of the drivebase to 1.2 degrees per second.
40 |
41 | # For example, if the light value deviates from the threshold by 10, the robot
42 | # steers at 10*1.2 = 12 degrees per second.
43 | PROPORTIONAL_GAIN = 1.2
44 |
45 | # Start following the line endlessly.
46 | while True:
47 | # Calculate the deviation from the threshold.
48 | deviation = line_sensor.reflection() - threshold
49 |
50 | # Calculate the turn rate.
51 | turn_rate = PROPORTIONAL_GAIN * deviation
52 |
53 | # Set the drive base speed and turn rate.
54 | robot.drive(DRIVE_SPEED, turn_rate)
55 |
56 | # You can wait for a short time or do other things in this loop.
57 | wait(10)
58 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_ultrasonic/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | .venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_ultrasonic/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_ultrasonic/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/robot_educator_ultrasonic/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false,
6 | "python.languageServer": "None"
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-core/sets_ev3_education_core.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": "color_sorter"
5 | },
6 | {
7 | "path": "gyro_boy"
8 | },
9 | {
10 | "path": "puppy"
11 | },
12 | {
13 | "path": "robot_arm"
14 | },
15 | {
16 | "path": "robot_educator_basic"
17 | },
18 | {
19 | "path": "robot_educator_line"
20 | },
21 | {
22 | "path": "robot_educator_ultrasonic"
23 | }
24 | ],
25 | "settings": {
26 | "debug.openDebug": "neverOpen"
27 | }
28 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/elephant/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/elephant/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/elephant/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/elephant/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/sets_ev3_education_expansion.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": "elephant"
5 | },
6 | {
7 | "path": "stair_climber"
8 | },
9 | {
10 | "path": "tank_bot"
11 | },
12 | {
13 | "path": "znap"
14 | }
15 | ],
16 | "settings": {
17 | "debug.openDebug": "neverOpen"
18 | }
19 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/stair_climber/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/stair_climber/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/stair_climber/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/stair_climber/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/tank_bot/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/tank_bot/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/tank_bot/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/tank_bot/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/znap/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/znap/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/znap/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/education-expansion/znap/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "python.linting.enabled": false
6 | }
7 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/bobb3e/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/bobb3e/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/bobb3e/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 |
7 | "configurations": [
8 | {
9 | "name": "Download and Run",
10 | "type": "ev3devBrowser",
11 | "request": "launch",
12 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
13 | "interactiveTerminal": false
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/bobb3e/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/bobb3e/bobb3e.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/bobb3e/bobb3e.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/bobb3e/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Bobb3e"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "bobb3e.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "i3jsJiVKYsg"
11 | description:
12 | "This remote controlled Bobcat® can be steered to move and lift objects with the control buttons on the IR Beacon."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_BOBB3E.pdf
15 | ---
16 |
17 |
18 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | Control Bobb3e as follows:
21 |
22 | - Make Bobb3e lower the forks by pressing the IR Remote Control's 2 Left Buttons together; make him raise the forks by pressing the 2 Right Buttons together
23 |
24 | - Drive Bobb3e around according to instructions from the IR Beacon:
25 | - 2 Top/Up Buttons together: drive forward
26 | - 2 Bottom/Down Buttons together: drive backward
27 | - Top-Left/Red-Up and Bottom-Right/Blue-Down together: turn left on the spot
28 | - Top-Right/Blue-Up and Bottom-Left/Red-Down together: turn right on the spot
29 | - Top-Left/Red-Up: turn left forward
30 | - Top-Right/Blue-Up: turn right forward
31 | - Bottom-Left/Red-Down: turn left backward
32 | - Bottom-Right/Blue-Down: turn right backward
33 |
34 | - Bobb3e beeps his alarm whenever reversing
35 |
36 | The code for the `Bobb3e` class is in `bobb3e.py` as follows:
37 |
38 | {% include copy-code.html %}
39 | ```python
40 | {% include_relative bobb3e.py %}
41 | ```
42 |
43 | The code for the main program is in `main.py` as follows:
44 |
45 | {% include copy-code.html %}
46 | ```python
47 | {% include_relative main.py %}
48 | ```
49 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/bobb3e/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from bobb3e import Bobb3e
5 |
6 | from pybricks.experimental import run_parallel
7 |
8 |
9 | bobb3e = Bobb3e()
10 |
11 | bobb3e.ev3_brick.screen.print('BOBB3E')
12 |
13 | run_parallel(
14 | bobb3e.drive_or_operate_forks_by_ir_beacon,
15 | bobb3e.sound_alarm_whenever_reversing)
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/dinor3x/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/dinor3x/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/dinor3x/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 |
7 | "configurations": [
8 | {
9 | "name": "Download and Run",
10 | "type": "ev3devBrowser",
11 | "request": "launch",
12 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
13 | "interactiveTerminal": false
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/dinor3x/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/dinor3x/dinor3x.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/dinor3x/dinor3x.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/dinor3x/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Dinor3x"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "dinor3x.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "eG5xdZ3l1AQ"
11 | description:
12 | "This charming robotic triceratops dinosaur is capable of walking and turning on all fours."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_DINOREX.pdf
15 | ---
16 |
17 |
18 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | NOTE: please add a Color Sensor to Dinor3x's back or tail.
21 |
22 | Dinor3x works as follows:
23 |
24 | - Dinor3x roars when the Beacon button is pressed
25 |
26 | - Dinor3x changes its speed when detecting some colors
27 | - Red: walk fast
28 | - Green: walk normally
29 | - White: walk slowly
30 |
31 | - Dinor3x walks or turns according to instructions from the IR Beacon
32 | - 2 top/up buttons together: walk forward
33 | - 2 bottom/down buttons together: walk backward
34 | - Top Left / Red Up: turn left on the spot
35 | - Top Right / Blue Up: turn right on the spot
36 | - Bottom Left / Red Down: stop
37 | - Bottom Right / Blue Down: calibrate to make the legs straight
38 |
39 | The code for the `Dinor3x` class is in `dinor3x.py` as follows:
40 |
41 | {% include copy-code.html %}
42 | ```python
43 | {% include_relative dinor3x.py %}
44 | ```
45 |
46 | The code for the main program is in `main.py` as follows:
47 |
48 | {% include copy-code.html %}
49 | ```python
50 | {% include_relative main.py %}
51 | ```
52 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/dinor3x/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from dinor3x import Dinor3x
5 |
6 |
7 | dino = Dinor3x()
8 |
9 | dino.close_mouth()
10 |
11 | while True:
12 | dino.roar_by_ir_beacon()
13 | dino.change_speed_by_color()
14 | dino.walk_by_ir_beacon()
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/el3ctric-guitar.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/el3ctric-guitar.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/el3ctric_guitar.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import EV3Brick
2 | from pybricks.ev3devices import Motor, TouchSensor, InfraredSensor
3 | from pybricks.media.ev3dev import ImageFile
4 | from pybricks.parameters import Color, Direction, Port, Stop
5 | from pybricks.tools import wait
6 |
7 |
8 | class El3ctricGuitar:
9 | NOTES = [1318, 1174, 987, 880, 783, 659, 587, 493, 440, 392, 329, 293]
10 | N_NOTES = len(NOTES)
11 |
12 | def __init__(
13 | self, lever_motor_port: Port = Port.D,
14 | touch_sensor_port: Port = Port.S1, ir_sensor_port: Port = Port.S4):
15 | self.ev3_brick = EV3Brick()
16 |
17 | self.lever_motor = Motor(port=lever_motor_port,
18 | positive_direction=Direction.CLOCKWISE)
19 |
20 | self.touch_sensor = TouchSensor(port=touch_sensor_port)
21 |
22 | self.ir_sensor = InfraredSensor(port=ir_sensor_port)
23 |
24 | def start_up(self):
25 | self.ev3_brick.screen.load_image(ImageFile.EV3)
26 |
27 | self.ev3_brick.light.on(color=Color.ORANGE)
28 |
29 | self.lever_motor.run_time(
30 | speed=50,
31 | time=1000,
32 | then=Stop.COAST,
33 | wait=True)
34 |
35 | self.lever_motor.run_angle(
36 | speed=50,
37 | rotation_angle=-30,
38 | then=Stop.BRAKE,
39 | wait=True)
40 |
41 | wait(100)
42 |
43 | self.lever_motor.reset_angle(angle=0)
44 |
45 | def play_note(self):
46 | if not self.touch_sensor.pressed():
47 | raw = sum(self.ir_sensor.distance() for _ in range(4)) / 4
48 |
49 | self.ev3_brick.speaker.beep(
50 | frequency=self.NOTES[
51 | min(int(raw / 5), self.N_NOTES - 1)
52 | ] - 11 * self.lever_motor.angle(),
53 | duration=100)
54 |
55 | wait(1)
56 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "El3ctric Guitar"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "el3ctric-guitar.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "WHOz3Zqkt5M"
11 | description:
12 | "Ready to to rock’n roll? This LEGO Guitar can be played almost like a real guitar. Stroke the string, slide your fingers across its fretless neck, and bend the notes using the tremolo bar to produce the most amazing guitar solos!"
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_EL3CTRIC%20GUITAR.pdf
15 | ---
16 |
17 |
18 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | The code for the `El3ctricGuitar` class is in `el3ctric_guitar.py` as follows:
21 |
22 | {% include copy-code.html %}
23 | ```python
24 | {% include_relative el3ctric_guitar.py %}
25 | ```
26 |
27 | The code for the main program is in `main.py` as follows:
28 |
29 | {% include copy-code.html %}
30 | ```python
31 | {% include_relative main.py %}
32 | ```
33 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/el3ctric-guitar/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from el3ctric_guitar import El3ctricGuitar
5 |
6 |
7 | guitar = El3ctricGuitar()
8 |
9 | guitar.start_up()
10 |
11 | while True:
12 | guitar.play_note()
13 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-d4/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-d4/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-d4/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 |
7 | "configurations": [
8 | {
9 | "name": "Download and Run",
10 | "type": "ev3devBrowser",
11 | "request": "launch",
12 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
13 | "interactiveTerminal": false
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-d4/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-d4/ev3-d4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/ev3-d4/ev3-d4.png
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-d4/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "EV3-D4"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "ev3-d4.png"
8 | credit: "LEGO"
9 | video:
10 | youtube: "rtmRZpR0lNA"
11 | description:
12 | "Inspired by R2D2 from Star Wars, this robot can interact with you, follow you wherever you go or move around the room wherever you want – all via the IR Beacon. The EV3D4 supports a wide set of behaviors that can easily be programmed or extended in the EV3 software."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_EV3D4.pdf
15 | ---
16 |
17 |
18 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | Drive EV3-D4 around according to instructions from Channel 1 of the IR Remote Control:
21 | - 2 Top/Up Buttons together: drive forward
22 | - 2 Bottom/Down Buttons together: drive backward
23 | - Top-Left/Red-Up: turn left forward
24 | - Top-Right/Blue-Up: turn right forward
25 | - Bottom-Left/Red-Down: turn left backward
26 | - Bottom-Right/Blue-Down: turn right backward
27 |
28 | Make him shake his head by pressing the IR Beacon button.
29 |
30 | Make him perform random funny actions by pressing his Touch Sensor or show his Color Sensor a red object.
31 |
32 | The code for the `EV3D4` class is in `ev3_d4.py` as follows:
33 |
34 | {% include copy-code.html %}
35 | ```python
36 | {% include_relative ev3_d4.py %}
37 | ```
38 |
39 | `EV3D4` uses a remote-controlled tank driving utility whose code is in `rc_tank_util.py` as follows:
40 |
41 | {% include copy-code.html %}
42 | ```python
43 | {% include_relative rc_tank_util.py %}
44 | ```
45 |
46 | The code for the main program is in `main.py` as follows:
47 |
48 | {% include copy-code.html %}
49 | ```python
50 | {% include_relative main.py %}
51 | ```
52 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-d4/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from threading import Thread
5 |
6 | from ev3_d4 import EV3D4
7 |
8 |
9 | ev3_d4 = EV3D4()
10 |
11 | Thread(target=ev3_d4.color_sensor_loop).start()
12 | Thread(target=ev3_d4.touch_sensor_loop).start()
13 | ev3_d4.main_switch_loop()
14 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-game/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-game/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-game/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 |
7 | "configurations": [
8 | {
9 | "name": "Download and Run",
10 | "type": "ev3devBrowser",
11 | "request": "launch",
12 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
13 | "interactiveTerminal": false
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-game/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-game/ev3-game.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/ev3-game/ev3-game.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-game/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Fan Robot: EV3 Game"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "ev3-game.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "OdSyquY3RXA&t"
11 | description:
12 | "This robot is all set to play tricks on you. Hide the red ball under the shell, use the IR Beacon to set your level, and watch the robot shuffle and hide the ball – but where? Challenge your friends to see who can find the red ball first!"
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_EV3%20GAME.pdf
15 | ---
16 |
17 |
18 | This program requires LEGO® EV3 MicroPython v2.0 downloadable https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | EV3Game works as follows:
21 |
22 | - Put a small ball or marble under the middle cup.
23 |
24 | - Choose the difficulty level by the IR beacon buttons: the Up buttons raise the level (up to 9) and the Down buttons lower the level (minimum 1). The level is printed on the screen.
25 |
26 | - Press the Touch Sensor to start the game and make the robot shuffle the cups.
27 |
28 | - Guess which cup has the ball by pressing:
29 | - Left Up IR button: choose left cup
30 | - Beacon IR button (press twice): choose middle cup
31 | - Right Up IR button: choose right cup
32 |
33 | - Repeat again and again to play many games.
34 |
35 | The code for the `EV3Game` class is in `ev3_game.py` as follows:
36 |
37 | {% include copy-code.html %}
38 | ```python
39 | {% include_relative ev3_game.py %}
40 | ```
41 |
42 | The code for the main program is in `main.py` as follows:
43 |
44 | {% include copy-code.html %}
45 | ```python
46 | {% include_relative main.py %}
47 | ```
48 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/ev3-game/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.media.ev3dev import SoundFile
5 | from pybricks.parameters import Color
6 | from pybricks.tools import wait
7 |
8 | from ev3_game import EV3Game
9 |
10 |
11 | ev3_game = EV3Game()
12 |
13 | ev3_game.start_up()
14 |
15 | while True:
16 | ev3_game.cup_with_ball = 2
17 |
18 | ev3_game.select_level()
19 |
20 | ev3_game.ev3_brick.light.on(color=Color.GREEN)
21 |
22 | ev3_game.shuffle()
23 |
24 | ev3_game.reset_motor_positions()
25 |
26 | ev3_game.ev3_brick.light.off()
27 |
28 | correct_choice = False
29 |
30 | while not correct_choice:
31 | ev3_game.select_choice()
32 |
33 | ev3_game.cup_to_center()
34 |
35 | # The choice will be now in the middle, Position 2
36 |
37 | ev3_game.lift_cup()
38 |
39 | correct_choice = (ev3_game.cup_with_ball == 2)
40 |
41 | if correct_choice:
42 | ev3_game.ev3_brick.light.on(color=Color.GREEN)
43 |
44 | ev3_game.ev3_brick.speaker.play_file(file=SoundFile.CHEERING)
45 |
46 | else:
47 | ev3_game.ev3_brick.light.on(color=Color.RED)
48 |
49 | ev3_game.ev3_brick.speaker.play_file(file=SoundFile.BOO)
50 |
51 | wait(2000)
52 |
53 | ev3_game.calibrate_grip()
54 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Official Fan Creations"
3 | number: 31313
4 | image:
5 | local: "rac3-truck/rac3-truck.jpeg"
6 | layout: set
7 | description: "Add set description"
8 | ---
9 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/kraz3/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/kraz3/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/kraz3/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 |
7 | "configurations": [
8 | {
9 | "name": "Download and Run",
10 | "type": "ev3devBrowser",
11 | "request": "launch",
12 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
13 | "interactiveTerminal": false
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/kraz3/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/kraz3/README.md:
--------------------------------------------------------------------------------
1 | # Example LEGO® MINDSTORMS® EV3 Kraz3 Program
2 |
3 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
4 |
5 | Building instructions can be found at https://www.lego.com/en-us/themes/mindstorms/buildarobot.
6 |
7 | Drive Kraz3 around according to instructions from Channel 1 of the IR Remote Control:
8 | - 2 Top/Up Buttons together: drive forward
9 | - 2 Bottom/Down Buttons together: drive backward
10 | - Top-Left/Red-Up: turn left forward
11 | - Top-Right/Blue-Up: turn right forward
12 | - Bottom-Left/Red-Down: turn left backward
13 | - Bottom-Right/Blue-Down: turn right backward
14 |
15 | Kraz3 makes a kung-fu move when you press the Touch Sensor or the IR Beacon button.
16 |
17 | Kraz3 reacts in funny ways to different colors.
18 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/kraz3/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Kraz3"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "kraz3.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "8rJMC98Pjqk"
11 | description:
12 | "This robot is fun companion with a crazy attitude that reacts to it’s little IR Beacon bug friend. You can control it with the custom program, the IR Beacon, or simply set it to follow it’s little friend around the room."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_KRAZ3.pdf
15 | ---
16 |
17 |
18 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | Drive Kraz3 around according to instructions from Channel 1 of the IR Remote Control:
21 | - 2 Top/Up Buttons together: drive forward
22 | - 2 Bottom/Down Buttons together: drive backward
23 | - Top-Left/Red-Up: turn left forward
24 | - Top-Right/Blue-Up: turn right forward
25 | - Bottom-Left/Red-Down: turn left backward
26 | - Bottom-Right/Blue-Down: turn right backward
27 |
28 | Kraz3 makes a kung-fu move when you press the Touch Sensor or the IR Beacon button.
29 |
30 | Kraz3 reacts in funny ways to different colors.
31 |
32 | The code for the `Kraz3` class is in `kraz3.py` as follows:
33 |
34 | {% include copy-code.html %}
35 | ```python
36 | {% include_relative kraz3.py %}
37 | ```
38 |
39 | `Kraz3` uses a remote-controlled tank driving utility whose code is in `rc_tank_util.py` as follows:
40 |
41 | {% include copy-code.html %}
42 | ```python
43 | {% include_relative rc_tank_util.py %}
44 | ```
45 |
46 | The code for the main program is in `main.py` as follows:
47 |
48 | {% include copy-code.html %}
49 | ```python
50 | {% include_relative main.py %}
51 | ```
52 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/kraz3/kraz3.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/kraz3/kraz3.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/kraz3/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.experimental import run_parallel
5 |
6 | from kraz3 import Kraz3
7 |
8 |
9 | kraz3 = Kraz3()
10 |
11 | run_parallel(
12 | kraz3.keep_driving_by_ir_beacon,
13 | kraz3.kungfu_manoeuvre_whenever_touched_or_remote_controlled,
14 | kraz3.keep_reacting_to_colors)
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/mr-b3am/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/mr-b3am/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/mr-b3am/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 |
7 | "configurations": [
8 | {
9 | "name": "Download and Run",
10 | "type": "ev3devBrowser",
11 | "request": "launch",
12 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
13 | "interactiveTerminal": false
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/mr-b3am/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/mr-b3am/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Mr. B3am"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "mr-b3am.png"
8 | credit: "LEGO"
9 | video:
10 | youtube: "dZYliR8eHSo"
11 | description:
12 | "This funny-looking robot is ready to organize all your LEGO® Technic beams. Simply insert the beams into the machine, and MR B3AM will detect their color and size."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_MR%20B3AM.pdf
15 | ---
16 |
17 |
18 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | NOTE: Mr. B3am can detect and measure accurately Black and Red Technic beams.
21 |
22 | The code for the `MrB3am` class is in `mr_b3am.py` as follows:
23 |
24 | {% include copy-code.html %}
25 | ```python
26 | {% include_relative mr_b3am.py %}
27 | ```
28 |
29 | The code for the main program is in `main.py` as follows:
30 |
31 | {% include copy-code.html %}
32 | ```python
33 | {% include_relative main.py %}
34 | ```
35 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/mr-b3am/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.parameters import Button, Color
5 | from pybricks.tools import wait
6 |
7 | from mr_b3am import MrB3am
8 |
9 |
10 | mr_b3am = MrB3am()
11 |
12 | while True:
13 | mr_b3am.process_b3am()
14 |
15 | mr_b3am.report_result(debug=True)
16 |
17 | mr_b3am.ev3_brick.screen.draw_text(
18 | x=0, y=105,
19 | text='Press Enter...',
20 | text_color=Color.BLACK,
21 | background_color=None)
22 |
23 | while Button.CENTER not in mr_b3am.ev3_brick.buttons.pressed():
24 | wait(10)
25 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/mr-b3am/mr-b3am.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/mr-b3am/mr-b3am.png
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/rac3-truck/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/rac3-truck/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/rac3-truck/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 |
7 | "configurations": [
8 | {
9 | "name": "Download and Run",
10 | "type": "ev3devBrowser",
11 | "request": "launch",
12 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
13 | "interactiveTerminal": false
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/rac3-truck/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/rac3-truck/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Rac3 Truck"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "rac3-truck.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "EAzsLYTumW4"
11 | description:
12 | "Want a remote controlled truck? Got it! This is one fun cool ride. You can modify the truck to make it go faster by adding gears, and you can add a custom-built trailer so the truck can be used as a transport vehicle."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_RAC3%20TRUCK.pdf
15 | ---
16 |
17 |
18 | This program requires LEGO® MINDSTORMS® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | Drive Rac3 Truck around according to instructions from Channel 1 of the IR Remote Control:
21 | - 2 Top/Up Buttons together: drive forward
22 | - 2 Bottom/Down Buttons together: drive backward
23 | - Top-Left/Red-Up: turn left forward
24 | - Top-Right/Blue-Up: turn right forward
25 | - Bottom-Left/Red-Down: turn left backward
26 | - Bottom-Right/Blue-Down: turn right backward
27 |
28 | The code for the `Rac3Truck` class is in `rac3_truck.py` as follows:
29 |
30 | {% include copy-code.html %}
31 | ```python
32 | {% include_relative rac3_truck.py %}
33 | ```
34 |
35 | The code for the main program is in `main.py` as follows:
36 |
37 | {% include copy-code.html %}
38 | ```python
39 | {% include_relative main.py %}
40 | ```
41 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/rac3-truck/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.tools import wait
5 |
6 | from rac3_truck import Rac3Truck
7 |
8 |
9 | rac3_truck = Rac3Truck()
10 |
11 | rac3_truck.reset()
12 |
13 | wait(1000)
14 |
15 | while True:
16 | rac3_truck.drive_by_ir_beacon()
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/rac3-truck/rac3-truck.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/rac3-truck/rac3-truck.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/robodoz3r/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/robodoz3r/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/robodoz3r/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 |
7 | "configurations": [
8 | {
9 | "name": "Download and Run",
10 | "type": "ev3devBrowser",
11 | "request": "launch",
12 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
13 | "interactiveTerminal": false
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/robodoz3r/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/robodoz3r/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | permalink: /projects/sets/mindstorms/ev3-home-bonus/robodoz3r/
3 | title: "LEGO Mindstorms EV3 Home Edition: Robodoz3r"
4 | maintainer:
5 | user: "TheVinhLuong102"
6 | name: "The Lương-Phạm Family"
7 | image:
8 | local: "robodoz3r.jpeg"
9 | credit: "LEGO"
10 | description:
11 | "This robot bulldozer can be controlled using the IR Beacon or it can drive on it’s own, avoiding obstacles while clearing and pushing things with its bulldozer bucket."
12 | building_instructions:
13 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_ROBODOZ3R.pdf
14 | ---
15 |
16 | # Example LEGO® MINDSTORMS® EV3 RoboDoz3r Program
17 |
18 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
19 |
20 | Building instructions can be found at https://www.lego.com/en-us/themes/mindstorms/buildarobot.
21 |
22 | Control RoboDoz3r as follows:
23 |
24 | - RoboDoz3r starts with the User-Controlled Mode. You can switch between the User-Controlled Mode and the Autonomous Mode by pressing the Touch Sensor.
25 |
26 | - User-Controlled Mode:
27 |
28 | - Drive RoboDoz3r around according to instructions from Channel 1 of the IR Remote Control:
29 | - 2 Top/Up Buttons together: drive forward
30 | - 2 Bottom/Down Buttons together: drive backward
31 | - Top-Left/Red-Up and Bottom-Right/Blue-Down together: turn left on the spot
32 | - Top-Right/Blue-Up and Bottom-Left/Red-Down together: turn right on the spot
33 | - Top-Left/Red-Up: turn left forward
34 | - Top-Right/Blue-Up: turn right forward
35 | - Bottom-Left/Red-Down: turn left backward
36 | - Bottom-Right/Blue-Down: turn right backward
37 |
38 | - Use Channel 4 of the IR Remote Control to make RoboDoz3r raise the shovel by pressing either Up button, or lower the shovel by pressing either Down button
39 |
40 | - Autonomous Mode: RoboDoz3r drives around on his own to clean up small things but avoids big obstacles by reversing and turning
41 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/robodoz3r/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.media.ev3dev import SoundFile
5 | from pybricks.tools import wait
6 |
7 | from time import time
8 |
9 | from robodoz3r import RoboDoz3r
10 |
11 |
12 | robodoz3r = RoboDoz3r()
13 |
14 | robodoz3r.ev3_brick.screen.print('ROBODOZ3R')
15 |
16 | robodoz3r.ev3_brick.speaker.play_file(SoundFile.MOTOR_START)
17 |
18 | motor_idle_start_time = time()
19 | while time() - motor_idle_start_time <= 2:
20 | robodoz3r.ev3_brick.speaker.play_file(SoundFile.MOTOR_IDLE)
21 |
22 | while True:
23 | while not robodoz3r.touch_sensor.pressed():
24 | robodoz3r.raise_or_lower_shovel_by_ir_beacon()
25 | robodoz3r.drive_by_ir_beacon(speed=1000)
26 | wait(10)
27 |
28 | robodoz3r.ev3_brick.speaker.play_file(SoundFile.AIRBRAKE)
29 |
30 | while not robodoz3r.touch_sensor.pressed():
31 | if robodoz3r.ir_sensor.distance() < 50:
32 | robodoz3r.driver.stop()
33 |
34 | wait(1000)
35 |
36 | robodoz3r.driver.straight(distance=-100)
37 |
38 | robodoz3r.driver.turn(angle=90)
39 |
40 | else:
41 | robodoz3r.driver.drive(
42 | speed=500,
43 | turn_rate=0)
44 |
45 | wait(10)
46 |
47 | robodoz3r.ev3_brick.speaker.play_file(SoundFile.AIRBRAKE)
48 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/robodoz3r/robodoz3r.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/robodoz3r/robodoz3r.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/sets-mindstorms-ev3-home-bonus.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": "bobb3e"
5 | },
6 | {
7 | "path": "dinor3x"
8 | },
9 | {
10 | "path": "el3ctric-guitar"
11 | },
12 | {
13 | "path": "ev3-game"
14 | },
15 | {
16 | "path": "ev3-d4"
17 | },
18 | {
19 | "path": "kraz3"
20 | },
21 | {
22 | "path": "mr-b3am"
23 | },
24 | {
25 | "path": "rac3-truck"
26 | },
27 | {
28 | "path": "robodoz3r"
29 | },
30 | {
31 | "path": "wack3m"
32 | }
33 | ],
34 |
35 | "settings": {
36 | "editor.rulers": [70],
37 |
38 | "ev3devBrowser.download.exclude": "{**/*.md,**/*.jpg,**/*.jpeg,**/*.png,**/*.pdf}",
39 | "ev3devBrowser.download.include": "**/*.py",
40 |
41 | "python.linting.enabled": true,
42 | "python.linting.pylintEnabled": true,
43 | "python.linting.flake8Enabled": true,
44 | "python.linting.mypyEnabled": true,
45 | "python.linting.pydocstyleEnabled": false,
46 | "python.linting.pycodestyleEnabled": true,
47 | "python.linting.prospectorEnabled": true,
48 | "python.linting.pylamaEnabled": true,
49 | "python.linting.banditEnabled": true
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/wack3m/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/wack3m/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 |
10 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11 | "unwantedRecommendations": [
12 | "ms-python.python"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/wack3m/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 |
6 | "version": "0.2.0",
7 |
8 | "configurations": [
9 | {
10 | "name": "Download and Run",
11 | "type": "ev3devBrowser",
12 | "request": "launch",
13 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
14 | "interactiveTerminal": false
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/wack3m/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "editor.rulers": [70],
4 |
5 | "ev3devBrowser.download.exclude": "{**/*.md,**/*.jpg,**/*.jpeg,**/*.png,**/*.pdf}",
6 | "ev3devBrowser.download.include": "**/*.py",
7 |
8 | "python.linting.enabled": true,
9 | "python.linting.pylintEnabled": false,
10 | "python.linting.flake8Enabled": true,
11 | "python.linting.mypyEnabled": true,
12 | "python.linting.pydocstyleEnabled": false,
13 | "python.linting.pycodestyleEnabled": true,
14 | "python.linting.prospectorEnabled": true,
15 | "python.linting.pylamaEnabled": true,
16 | "python.linting.banditEnabled": true
17 | }
18 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/wack3m/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Wack3m"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "wack3m.jpg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "ksojLbHrhJ8"
11 | description:
12 | "Arcade-style game that tests your reaction speed."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_WACK3M.pdf
15 | ---
16 |
17 |
18 | Designed by [Martyn Boogaarts](https://www.robotmak3rs.com/Martyn-Boogarts). This is an arcade-style game that tests your reaction speed. The robot pops up disks that you have to whack as quickly as possible using the wack-wheel hammer. Challenge your friends and see who wackedy-wacks the fastest!
19 |
20 | This program requires [LEGO® MINDSTORMS® EV3 MicroPython v2.0](https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3) installed on the EV3 Hub.
21 |
22 | How to play: Press the Touch Sensor to start a game. Each game has ten rounds of whacking, and your average response time is measured.
23 |
24 | The code for the `Wack3m` class is in `wack3m.py` as follows:
25 |
26 | {% include copy-code.html %}
27 | ```python
28 | {% include_relative wack3m.py %}
29 | ```
30 |
31 | The code for the main program is in `main.py` as follows:
32 |
33 | {% include copy-code.html %}
34 | ```python
35 | {% include_relative main.py %}
36 | ```
37 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/wack3m/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from wack3m import Wack3m
5 |
6 |
7 | wack3m = Wack3m()
8 |
9 | wack3m.start_up()
10 | wack3m.play()
11 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-bonus/wack3m/wack3m.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-bonus/wack3m/wack3m.jpg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/ev3rstorm/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/ev3rstorm/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/ev3rstorm/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/ev3rstorm/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/ev3rstorm/ev3rstorm.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-main/ev3rstorm/ev3rstorm.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/ev3rstorm/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Ev3rstorm"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "ev3rstorm.jpeg"
8 | credit: "LEGO"
9 | description:
10 | "EV3RSTORM is the most advanced of the LEGO® MINDSTORMS® robots. Equipped with a blasting bazooka and a spinning tri-blade, EV3RSTORM is superior in both intelligence as well as in fighting power."
11 | building_instructions:
12 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_EV3RSTORM.pdf
13 | ---
14 |
15 |
16 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
17 |
18 | Ev3rstorm works as follows:
19 |
20 | - You can drive Ev3rstorm around with the IR beacon.
21 |
22 | - Ev3rstorm dances by turning by random angles on the spot when the Beacon button is pressed.
23 |
24 | - Ev3rstorm blasts his bazooka when his Touch Sensor is pressed. If you cover the Color Sensor then he will shoot upwards, or he will shoot downwards.
25 |
26 | The code for the `Ev3rstorm` class is in `ev3rstorm.py` as follows:
27 |
28 | {% include copy-code.html %}
29 | ```python
30 | {% include_relative ev3rstorm.py %}
31 | ```
32 |
33 | `Ev3rstorm` uses a remote-controlled tank driving utility whose code is in `rc_tank_util.py` as follows:
34 |
35 | {% include copy-code.html %}
36 | ```python
37 | {% include_relative rc_tank_util.py %}
38 | ```
39 |
40 | The code for the main program is in `main.py` as follows:
41 |
42 | {% include copy-code.html %}
43 | ```python
44 | {% include_relative main.py %}
45 | ```
46 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/ev3rstorm/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.media.ev3dev import ImageFile
5 | from pybricks.tools import wait
6 |
7 | from ev3rstorm import Ev3rstorm
8 |
9 |
10 | ev3rstorm = Ev3rstorm()
11 |
12 | ev3rstorm.ev3_brick.screen.load_image(ImageFile.TARGET)
13 |
14 | while True:
15 | ev3rstorm.drive_by_ir_beacon(speed=1000)
16 | ev3rstorm.dance_randomly_if_ir_beacon_button_pressed()
17 | ev3rstorm.blast_bazooka_if_touched()
18 | wait(1)
19 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/gripp3r/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/gripp3r/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/gripp3r/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/gripp3r/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/gripp3r/gripp3r.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-main/gripp3r/gripp3r.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/gripp3r/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Gripp3r"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "gripp3r.jpeg"
8 | credit: "LEGO"
9 | description:
10 | "The GRIPP3R robot is constructed for some heavy-duty lifting. It’s got the muscle to grab and drop a can of soda with its powerful grasping grippers."
11 | building_instructions:
12 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_GRIPP3R.pdf
13 | ---
14 |
15 |
16 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
17 |
18 | You can drive Gripp3r around and make it grip or release objects by the IR beacon.
19 |
20 | The code for the `Gripp3r` class is in `gripp3r.py` as follows:
21 |
22 | {% include copy-code.html %}
23 | ```python
24 | {% include_relative gripp3r.py %}
25 | ```
26 |
27 | `Gripp3r` uses a remote-controlled tank driving utility whose code is in `rc_tank_util.py` as follows:
28 |
29 | {% include copy-code.html %}
30 | ```python
31 | {% include_relative rc_tank_util.py %}
32 | ```
33 |
34 | The code for the main program is in `main.py` as follows:
35 |
36 | {% include copy-code.html %}
37 | ```python
38 | {% include_relative main.py %}
39 | ```
40 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/gripp3r/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.parameters import Stop
5 | from pybricks.tools import wait
6 |
7 | from gripp3r import Gripp3r
8 |
9 |
10 | gripp3r = Gripp3r()
11 |
12 | gripp3r.gripping_motor.run_time(
13 | speed=-500,
14 | time=1000,
15 | then=Stop.COAST,
16 | wait=True)
17 |
18 | while True:
19 | gripp3r.drive_by_ir_beacon(speed=1000)
20 | gripp3r.grip_or_release_by_ir_beacon(speed=500)
21 | wait(1)
22 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Main models"
3 | number: 31313
4 | image:
5 | local: "mindstorms-ev3-home.jpg"
6 | layout: set
7 | description: "Add set description"
8 | ---
9 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/mindstorms-ev3-home.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-main/mindstorms-ev3-home.jpg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/r3ptar/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/r3ptar/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/r3ptar/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/r3ptar/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/r3ptar/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "R3ptar"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "r3ptar.jpeg"
8 | credit: "LEGO"
9 | description:
10 | "One of the most loved robots, the standing 35 cm. / 13.8 inch tall R3PTAR robot slithers across the floor like a real cobra, and strikes at lightning speed with it’s pointed red fangs."
11 | building_instructions:
12 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_R3PTAR.pdf
13 | ---
14 |
15 |
16 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
17 |
18 | R3ptar can be driven around by the IR Remote Control, strikes when the Beacon button is pressed, and hisses when the Touch Sensor is pressed.
19 |
20 | The code for the `R3ptar` class is in `r3ptar.py` as follows:
21 |
22 | {% include copy-code.html %}
23 | ```python
24 | {% include_relative r3ptar.py %}
25 | ```
26 |
27 | The code for the main program is in `main.py` as follows:
28 |
29 | {% include copy-code.html %}
30 | ```python
31 | {% include_relative main.py %}
32 | ```
33 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/r3ptar/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.tools import wait
5 |
6 | from r3ptar import R3ptar
7 |
8 |
9 | r3ptar = R3ptar()
10 |
11 | while True:
12 | r3ptar.drive_by_ir_beacon(speed=1000)
13 | r3ptar.strike_by_ir_beacon(speed=1000)
14 | r3ptar.hiss_if_touched()
15 | wait(1)
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/r3ptar/r3ptar.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-main/r3ptar/r3ptar.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/sets_ev3_home.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": "ev3rstorm"
5 | },
6 | {
7 | "path": "gripp3r"
8 | },
9 | {
10 | "path": "r3ptar"
11 | },
12 | {
13 | "path": "spik3r"
14 | },
15 | {
16 | "path": "track3r"
17 | }
18 | ],
19 | "settings": {
20 | "debug.openDebug": "neverOpen"
21 | }
22 | }
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/spik3r/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/spik3r/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/spik3r/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/main.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/spik3r/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/spik3r/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Spik3r"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "spik3r.jpeg"
8 | credit: "LEGO"
9 | description:
10 | "This six-legged creature doesn’t just look like a scorpion, it also acts like one. It turns sharply, snaps with it’s crushing claw, and it’s lightning tail is ready to fire at anyone or anything that gets in its way."
11 | building_instructions:
12 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.extra.pdf/31313_X_SPIK3R.pdf
13 | ---
14 |
15 |
16 | This program requires LEGO® EV3 MicroPython v2.0 downloadable at https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3.
17 |
18 | Spik3r works as follows:
19 |
20 | - Spik3r stings with its Lightning Tail when the Beacon button is pressed
21 |
22 | - Spik3r moves forward when the IR Beacon's two Up buttons are pressed, and turns right when only the Right Up button is pressed
23 |
24 | - Spik3r crushes objects with its Claw when the Touch Sensor is pressed
25 |
26 | The code for the `Spik3r` class is in `spik3r.py` as follows:
27 |
28 | {% include copy-code.html %}
29 | ```python
30 | {% include_relative spik3r.py %}
31 | ```
32 |
33 | The code for the main program is in `main.py` as follows:
34 |
35 | {% include copy-code.html %}
36 | ```python
37 | {% include_relative main.py %}
38 | ```
39 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/spik3r/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.media.ev3dev import ImageFile
5 | from pybricks.tools import wait
6 |
7 | from spik3r import Spik3r
8 |
9 |
10 | spik3r = Spik3r()
11 |
12 | spik3r.ev3_brick.screen.load_image(ImageFile.WARNING)
13 |
14 | while True:
15 | spik3r.move_by_ir_beacon(speed=1000)
16 | spik3r.sting_by_ir_beacon(speed=1000)
17 | spik3r.pinch_if_touched(speed=1000)
18 | wait(1)
19 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/spik3r/spik3r.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-main/spik3r/spik3r.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__/
2 | *.pyc
3 | venv/
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4 |
5 | // List of extensions which should be recommended for users of this workspace.
6 | "recommendations": [
7 | "lego-education.ev3-micropython"
8 | ],
9 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10 | "unwantedRecommendations": [
11 | "ms-python.python"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Download and Run",
9 | "type": "ev3devBrowser",
10 | "request": "launch",
11 | "program": "/home/robot/${workspaceRootFolderName}/track3r_base.py",
12 | "interactiveTerminal": false
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | // Place your settings in this file to overwrite default and user settings.
2 | {
3 | "files.eol": "\n",
4 | "debug.openDebug": "neverOpen",
5 | "editor.rulers": [79],
6 | "python.linting.flake8Enabled": true
7 | }
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/track3r.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-ev3/home-main/track3r/track3r.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/track3r_base.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.hubs import EV3Brick
5 | from pybricks.ev3devices import Motor
6 | from pybricks.parameters import Direction, Port
7 | from pybricks.tools import wait
8 |
9 | from rc_tank_util import RemoteControlledTank
10 |
11 |
12 | class Track3r(RemoteControlledTank):
13 | WHEEL_DIAMETER = 26 # milimeters
14 | AXLE_TRACK = 140 # milimeters
15 |
16 | def __init__(
17 | self,
18 | left_track_motor_port: Port = Port.B,
19 | right_track_motor_port: Port = Port.C,
20 | medium_motor_port: Port = Port.A,
21 | ir_sensor_port: Port = Port.S4,
22 | ir_beacon_channel: int = 1):
23 | super().__init__(
24 | wheel_diameter=self.WHEEL_DIAMETER,
25 | axle_track=self.AXLE_TRACK,
26 | left_motor_port=left_track_motor_port,
27 | right_motor_port=right_track_motor_port,
28 | ir_sensor_port=ir_sensor_port,
29 | ir_beacon_channel=ir_beacon_channel)
30 |
31 | self.ev3_brick = EV3Brick()
32 |
33 | self.medium_motor = Motor(port=medium_motor_port,
34 | positive_direction=Direction.CLOCKWISE)
35 |
36 | def main(self, speed: float = 1000):
37 | """
38 | Driving Track3r around by the IR beacon
39 | """
40 | while True:
41 | self.drive_by_ir_beacon(speed=speed)
42 | wait(1)
43 |
44 |
45 | if __name__ == '__main__':
46 | TRACK3R = Track3r()
47 | TRACK3R.main(speed=1000)
48 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/track3r_with_biblade_spinner.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.parameters import Button
5 | from pybricks.tools import wait
6 |
7 | from track3r_base import Track3r
8 |
9 |
10 | class Track3rWithBiBladeSpinner(Track3r):
11 | """
12 | Track3r spins its blade when the Beacon button is pressed
13 | (inspiration from LEGO Mindstorms EV3 Home Edition: Track3r: Tutorial #5)
14 | """
15 | def spin_blade_by_ir_beacon(self, speed: float = 1000):
16 | if Button.BEACON in \
17 | self.ir_sensor.buttons(channel=self.ir_beacon_channel):
18 | self.medium_motor.run(speed=speed)
19 |
20 | else:
21 | self.medium_motor.stop()
22 |
23 | def main(self, speed: float = 1000):
24 | while True:
25 | self.drive_by_ir_beacon(speed=speed)
26 | self.spin_blade_by_ir_beacon(speed=speed)
27 | wait(1)
28 |
29 |
30 | if __name__ == '__main__':
31 | TRACK3R = Track3rWithBiBladeSpinner()
32 | TRACK3R.main(speed=1000)
33 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/track3r_with_blasting_bazooka.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.media.ev3dev import ImageFile, SoundFile
5 | from pybricks.parameters import Button, Stop
6 | from pybricks.tools import wait
7 |
8 | from track3r_base import Track3r
9 |
10 |
11 | class Track3rWithBlastingBazooka(Track3r):
12 | """
13 | Track3r blasts his bazooka when the Beacon button is pressed
14 | (inspiration from LEGO Mindstorms EV3 Home Edition: Track3r: Tutorial #2)
15 | """
16 | def blast_bazooka_by_ir_beacon(self, speed: float = 1000):
17 | if Button.BEACON in \
18 | self.ir_sensor.buttons(channel=self.ir_beacon_channel):
19 | self.medium_motor.run_angle(
20 | speed=speed,
21 | rotation_angle=3 * 360, # about 3 rotations for 1 shot
22 | then=Stop.HOLD,
23 | wait=True)
24 |
25 | self.ev3_brick.speaker.play_file(file=SoundFile.LAUGHING_1)
26 |
27 | while Button.BEACON in \
28 | self.ir_sensor.buttons(channel=self.ir_beacon_channel):
29 | pass
30 |
31 | def main(self, speed: float = 1000):
32 | self.ev3_brick.screen.load_image(ImageFile.PINCHED_MIDDLE)
33 |
34 | while True:
35 | self.drive_by_ir_beacon(speed=speed)
36 | self.blast_bazooka_by_ir_beacon(speed=speed)
37 | wait(1)
38 |
39 |
40 | if __name__ == '__main__':
41 | TRACK3R = Track3rWithBlastingBazooka()
42 | TRACK3R.main(speed=1000)
43 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/track3r_with_gripping_claw.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.media.ev3dev import SoundFile
5 | from pybricks.parameters import Button
6 | from pybricks.tools import wait
7 |
8 | from track3r_base import Track3r
9 |
10 |
11 | class Track3rWithGrippingClaw(Track3r):
12 | """
13 | Track3r grips or releases its claw when the Beacon button is pressed
14 | (inspiration from LEGO Mindstorms EV3 Home Edition: Track3r: Tutorial #3)
15 | """
16 | is_gripping = False
17 |
18 | def grip_or_release_claw_by_ir_beacon(self, speed: float = 1000):
19 | if Button.BEACON in \
20 | self.ir_sensor.buttons(channel=self.ir_beacon_channel):
21 | if self.is_gripping:
22 | self.medium_motor.run(speed=-speed)
23 | self.ev3_brick.speaker.play_file(file=SoundFile.AIR_RELEASE)
24 | self.is_gripping = False
25 |
26 | else:
27 | self.medium_motor.run(speed=speed)
28 | self.ev3_brick.speaker.play_file(file=SoundFile.AIRBRAKE)
29 | self.is_gripping = True
30 |
31 | while Button.BEACON in \
32 | self.ir_sensor.buttons(channel=self.ir_beacon_channel):
33 | pass
34 |
35 | def main(self, speed: float = 1000):
36 | while True:
37 | self.drive_by_ir_beacon(speed=speed)
38 | self.grip_or_release_claw_by_ir_beacon(speed=speed)
39 | wait(1)
40 |
41 |
42 | if __name__ == '__main__':
43 | TRACK3R = Track3rWithGrippingClaw()
44 | TRACK3R.main(speed=1000)
45 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/home-main/track3r/track3r_with_heavy_hammer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pybricks-micropython
2 |
3 |
4 | from pybricks.media.ev3dev import ImageFile, SoundFile
5 | from pybricks.parameters import Button, Stop
6 | from pybricks.tools import wait
7 |
8 | from track3r_base import Track3r
9 |
10 |
11 | class Track3rWithHeavyHammer(Track3r):
12 | """
13 | Track3r hammers down when the Beacon button is pressed
14 | (inspiration from LEGO Mindstorms EV3 Home Edition: Track3r: Tutorial #4)
15 | """
16 | def hammer_by_ir_beacon(self, speed: float = 1000):
17 | if Button.BEACON in \
18 | self.ir_sensor.buttons(channel=self.ir_beacon_channel):
19 | self.ev3_brick.screen.load_image(ImageFile.ANGRY)
20 |
21 | self.medium_motor.run_time(
22 | speed=speed,
23 | time=1000,
24 | then=Stop.COAST,
25 | wait=True)
26 |
27 | self.ev3_brick.speaker.play_file(file=SoundFile.LAUGHING_2)
28 |
29 | self.medium_motor.run_time(
30 | speed=-speed,
31 | time=1000,
32 | then=Stop.COAST,
33 | wait=True)
34 |
35 | def main(self, speed: float = 1000):
36 | self.medium_motor.run_time(
37 | speed=-200,
38 | time=1000,
39 | then=Stop.COAST,
40 | wait=True)
41 |
42 | while True:
43 | self.drive_by_ir_beacon(speed=speed)
44 | self.hammer_by_ir_beacon(speed=speed)
45 | wait(1)
46 |
47 |
48 | if __name__ == '__main__':
49 | TRACK3R = Track3rWithHeavyHammer()
50 | TRACK3R.main(speed=1000)
51 |
--------------------------------------------------------------------------------
/sets/mindstorms-ev3/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "MINDSTORMS EV3"
3 | layout: theme
4 | description: "Theme description"
5 | ---
6 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/fan-inventions/exploration-rover/exploration-rover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/fan-inventions/exploration-rover/exploration-rover.jpg
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/fan-inventions/exploration-rover/exploration-rover.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/fan-inventions/exploration-rover/exploration-rover.pdf
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/fan-inventions/exploration-rover/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Exploration Rover"
3 | maintainer:
4 | user: "laurensvalk"
5 | name: "Laurens Valk"
6 | image:
7 | local: "exploration-rover.jpg"
8 | video:
9 | youtube: "3gbAc6iKAJg"
10 | description:
11 | "Six-wheeled rover with instruments to explore new worlds."
12 | building_instructions:
13 | local: "exploration-rover.pdf"
14 | code: "#program"
15 | ---
16 |
17 | ## Description
18 |
19 | TODO
20 |
21 | ## Program
22 |
23 |
24 | {% include copy-code.html %}
25 | ```python
26 | {% include_relative main.py %}
27 | ```
28 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/fan-inventions/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Official Fan Inventions"
3 | number: 51515
4 | image:
5 | local: "exploration-rover/exploration-rover.jpg"
6 | layout: set
7 | description: "Add set description"
8 | ---
9 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "MINDSTORMS Robot Inventor"
3 | layout: theme
4 | description: "Theme description"
5 | ---
6 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/.gitignore:
--------------------------------------------------------------------------------
1 | # Visual Studio Code
2 | .vscode/
3 | *.code-workspace
4 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/blast/blast.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/main-models/blast/blast.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/blast/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Blast"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "blast.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "5Fa4m1XzlCA"
11 | description:
12 | "This master robot is a stoic action hero. It can fire or hammer its way through obstacles and grab items. Builders can be the ultimate commanders, programming it to scan its environment and fire darts if it senses danger. Perfect for guarding your room!"
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_Blast.pdf
15 | code: "#program"
16 | ---
17 |
18 | ## Program
19 | The playing instructions for each robot variant are in the docstrings of the corresponding file.
20 |
21 | The code for Blast's basic dance is in `blast-basic.py` as follows:
22 |
23 | {% include copy-code.html %}
24 | ```python
25 | {% include_relative blast-basic.py %}
26 | ```
27 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/basic.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "A Simple Gelo Program"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "../gelo.jpg"
8 | credit: "LEGO"
9 | code: "#program"
10 | ---
11 |
12 |
13 | ## Program
14 |
15 | The playing instructions for each robot variant are in the docstrings of the corresponding file.
16 |
17 | The code for Gelo's basic walk is in `gelo_basic.py` as follows:
18 |
19 | {% include copy-code.html %}
20 | ```python
21 | {% include_relative gelo_basic.py %}
22 | ```
23 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/gelo-bone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/main-models/gelo/gelo-bone.png
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/gelo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/main-models/gelo/gelo.jpg
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/gelo_repl.py:
--------------------------------------------------------------------------------
1 | from gelo import Gelo
2 |
3 | gelo = Gelo()
4 |
5 | # Normally, we don't call methods with
6 | # double-underscores directly, but this
7 | # is an exceptional case!
8 | gelo.__enter__()
9 |
10 | # A KeyboardInterrupt will stop the
11 | # program and start the interactive
12 | # prompt. You can also trigger this
13 | # in any running program by pressing
14 | # CTRL+C in the terminal.
15 | raise KeyboardInterrupt
16 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/gelo_roam.py:
--------------------------------------------------------------------------------
1 | from pybricks.parameters import Icon
2 | from urandom import choice
3 | from gelo import Gelo
4 |
5 | with Gelo() as gelo:
6 | # If the ultrasonic sensor measures less than
7 | # 30 cm (1 ft), then we are too close!
8 | def too_close():
9 | return gelo.ultrasonic.distance() < 300
10 |
11 | while True:
12 | # walk until the ultrasonic sensor detects an obstruction
13 | gelo.hub.display.icon(Icon.ARROW_UP)
14 | gelo.walk_until(too_close)
15 |
16 | # randomly turn left or right to avoid the obstruction
17 | direction = choice(["left", "right"])
18 |
19 | if choice == "left":
20 | gelo.hub.display.icon(Icon.ARROW_LEFT)
21 | gelo.walk(steer=90, time=4000)
22 | else:
23 | gelo.hub.display.icon(Icon.ARROW_RIGHT)
24 | gelo.walk(steer=-90, time=4000)
25 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/gelo_template.py:
--------------------------------------------------------------------------------
1 | from pybricks.parameters import Button, Color, Icon
2 | from pybricks.tools import wait, StopWatch
3 |
4 | from gelo import Gelo
5 |
6 |
7 | with Gelo() as gelo:
8 | # Add your code here
9 | gelo.walk()
10 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Gelo"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "gelo.jpg"
8 | credit: "LEGO"
9 | description:
10 | "Gelo is a 4-legged robot that operates autonomously or via remote control. It can even do tricks!"
11 | building_instructions:
12 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_Gelo.pdf
13 | code: "#gelo-module"
14 | ---
15 |
16 | ## Activities
17 |
18 | These activities are similar to the starter programs available in the official
19 | LEGO app.
20 |
21 | First copy the [Gelo module](#gelo-module) below and save it in Pybricks Code.
22 | It is used by all of the activities. Then follow one of the links below.
23 |
24 | - [Roam around](./roam): Gelo walks around uses the ultrasonic sensor to avoid obstacles.
25 | - [Tricks](./tricks): Use the color sensor to tell Gelo to do a trick for you.
26 | - [Remote control](./remote): Use the LEGO Powered Up remote to control Gelo.
27 | - [Command prompt](./repl): Use the interactive command prompt in Pybricks Code to control Gelo.
28 | - [Make your own program](./template): A starter template for writing your own program.
29 |
30 | ## Gelo module
31 |
32 | Save this program as `gelo.py` in Pybricks Code. It is used in the
33 | [activities](#activities) above.
34 |
35 | {% include copy-code.html %}
36 | ```python
37 | {% include_relative gelo.py %}
38 | ```
39 |
40 | ## Basic program
41 |
42 | If you are looking for something less complex, try out this [basic](./basic) program.
43 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/remote.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Remote control Gelo"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "../gelo.jpg"
8 | credit: "LEGO"
9 | building_instructions:
10 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_Gelo.pdf
11 | code: "#program"
12 | ---
13 |
14 | ## Instructions
15 |
16 | This program requires the LEGO Powered Up remote control. The left +
17 | and - buttons control the speed and the right + and
18 | - buttons control the steering. Either red button will make Gelo stop.
19 |
20 | 
21 |
22 | This script makes use of the [gelo.py](../#gelo-module) module, so make
23 | sure to save that program in Pybricks Code first.
24 |
25 | Then save the script below as `gelo_remote.py` and run it.
26 |
27 | When the program starts, the light will turn yellow. This means Gelo is waiting
28 | to connect to the remote control. Turn on the remote and it will connect
29 | automatically and the light on Gelo will turn green. Then you can press the
30 | buttons on the remote to control Gelo.
31 |
32 | ## Program
33 |
34 | {% include copy-code.html %}
35 | ```python
36 | {% include_relative gelo_remote.py %}
37 | ```
38 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/remote.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/main-models/gelo/remote.png
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/repl.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Command prompt
3 | description: Control Gelo with the interactive command prompt
4 | maintainer:
5 | user: "pybricks"
6 | name: "The Pybricks Team"
7 | image:
8 | local: ../gelo.jpg
9 | credit: LEGO
10 | building_instructions:
11 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_Gelo.pdf
12 | code: "#program"
13 | ---
14 |
15 | ## Using the command prompt
16 |
17 | Python has an interactive command prompt. This is also sometimes called the
18 | REPL (Read Evaluate Print Loop). It can be used to run Python code as you
19 | type it in.
20 |
21 | Save the program below as `gelo_repl.py` in Pybricks Code. And make sure you
22 | have the [gelo.py](../#gelo-module) saved there too.
23 |
24 | Then connect to Gelo and run the program. In the terminal window in Pybricks
25 | Code, you will see a prompt like this:
26 |
27 | ```
28 | >>>
29 | ```
30 |
31 | Type in a command like this and press enter:
32 |
33 | ```
34 | >>> gelo.walk()
35 | ```
36 |
37 | ### Tips
38 |
39 | * To save some typing, after typing `gelo.`, you can press the tab
40 | key to provide a list of available methods. Then type the first few letters
41 | and press tab again to complete the name.
42 | * To cancel a running command, you can press ctrl+c.
43 |
44 |
45 | ## Program
46 |
47 | {% include copy-code.html %}
48 | ```python
49 | {% include_relative gelo_repl.py %}
50 | ```
51 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/roam.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Obstacle avoidance with Gelo
3 | description: Gelo can autonomously roam around and avoid obstacles by using the ultrasonic sensor.
4 | maintainer:
5 | user: "pybricks"
6 | name: "The Pybricks Team"
7 | image:
8 | local: ../gelo.jpg
9 | credit: LEGO
10 | code: "#program"
11 | ---
12 |
13 | ## Quick start
14 |
15 | This script makes use of the [gelo.py](../#gelo-module) module, so make
16 | sure to save that program in Pybricks Code first.
17 |
18 | Then save the script below as `gelo_roam.py` and run it.
19 |
20 | Gelo will walk forward until it "sees" an obstacle. Then it will randomly turn
21 | left or right then start walking again until it sees the next obstacle.
22 |
23 | ## Program
24 |
25 | {% include copy-code.html %}
26 | ```python
27 | {% include_relative gelo_roam.py %}
28 | ```
29 |
30 | ## Change it up
31 |
32 | Try changing the program to attack obstacles instead avoiding them.
33 |
34 | * Change the main loop to turn until an obstacle is detected.
35 | * Then walk towards the obstacle until Gelo crashes into it!
36 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/template.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Make your own Gelo program
3 | description: A basic template for your own Gelo program.
4 | maintainer:
5 | user: "pybricks"
6 | name: "The Pybricks Team"
7 | image:
8 | local: ../gelo.jpg
9 | credit: LEGO
10 | building_instructions:
11 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_Gelo.pdf
12 | code: "#program"
13 | ---
14 |
15 |
16 | ## Program
17 |
18 | Use this script as a starting point for your own Gelo program.
19 |
20 | This script makes use of the [gelo.py](../#gelo-module) module, so make
21 | sure to save that program in Pybricks Code first.
22 |
23 | ### Tip
24 |
25 | In Pybricks Code, type `gelo` and then `.` to see what Gelo can do and get help
26 | on what parameters you can pass to the methods.
27 |
28 | {% include copy-code.html %}
29 | ```python
30 | {% include_relative gelo_template.py %}
31 | ```
32 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/gelo/tricks.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Make Gelo Do Tricks
3 | description: Use the color sensor to make Gelo perform a trick.
4 | maintainer:
5 | user: "pybricks"
6 | name: "The Pybricks Team"
7 | image:
8 | local: ../gelo.jpg
9 | credit: LEGO
10 | building_instructions:
11 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_Gelo.pdf
12 | code: "#program"
13 | ---
14 |
15 | ## Instructions
16 |
17 | This script makes use of the [gelo.py](../#gelo-module) module, so make
18 | sure to save that program in Pybricks Code first.
19 |
20 | Then save the script below as `gelo_tricks.py` and run it.
21 |
22 | 
23 |
24 |
25 | Wave one of the colors on the bone in front of the color sensor on Gelo and
26 | watch which trick he does.
27 |
28 | The tricks work best when Gelo is on carpet where he can get a good grip.
29 |
30 | ## Program
31 |
32 | {% include copy-code.html %}
33 | ```python
34 | {% include_relative gelo_tricks.py %}
35 | ```
36 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Main Models"
3 | number: 51515
4 | image:
5 | local: "robot-inventor.jpg"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Add set description"
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/mvp/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "M.V.P."
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "mvp.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "5Fa4m1XzlCA"
11 | description:
12 | "The Modular Vehicle Platform gets the job done. Create and code your own remote control and build the M.V.P. into a buggy, a crane, a shooter turret or even a brick-eating truck to pick up LEGO bricks left by the other robots."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_MVP.pdf
15 | code: "#program"
16 | ---
17 |
18 | ## Program
19 | The playing instructions for each robot variant are in the docstrings of the corresponding file.
20 |
21 | The code for M.V.P.'s basic drive is in `mvp-basic.py` as follows:
22 |
23 | {% include copy-code.html %}
24 | ```python
25 | {% include_relative mvp-basic.py %}
26 | ```
27 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/mvp/mvp-basic.py:
--------------------------------------------------------------------------------
1 | """
2 | This program is for MVP's basic "Buggy" mode.
3 |
4 | Follow the corresponding building instructions in the LEGO® MINDSTORMS®
5 | Robot Inventor App.
6 | """
7 |
8 | from pybricks.pupdevices import Motor
9 | from pybricks.parameters import Direction, Port
10 |
11 |
12 | class MVP:
13 | def __init__(self):
14 | self.steer_motor = Motor(Port.A)
15 | self.drive_motor = Motor(Port.B,
16 | positive_direction=Direction.COUNTERCLOCKWISE)
17 |
18 | def calibrate(self):
19 | self.steer_motor.run_target(speed=1000, target_angle=0)
20 |
21 |
22 | # Initialize mvp and straighten its steering.
23 | mvp = MVP()
24 | mvp.calibrate()
25 |
26 | # Make mvp drive in a circle.
27 | mvp.steer_motor.run_angle(speed=350, rotation_angle=50)
28 | mvp.drive_motor.run_angle(speed=800, rotation_angle=16 * 360)
29 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/mvp/mvp.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/main-models/mvp/mvp.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/robot-inventor.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/main-models/robot-inventor.jpg
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/tricky/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Tricky"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "tricky.jpeg"
8 | credit: "LEGO"
9 | video:
10 | youtube: "5Fa4m1XzlCA"
11 | description:
12 | "The sporty bot is the ultimate athlete. Code it to complete the perfect slam dunk or master a plethora of robot sports: basketball, bowling or soccer – the list goes on and on."
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_Tricky.pdf
15 | code: "#programs"
16 | ---
17 |
18 | ## Programs
19 |
20 | The playing instructions for each robot variant are in the docstrings of the corresponding file.
21 |
22 |
23 | The code for Tricky's basic dance is in `tricky-basic.py` as follows:
24 |
25 | {% include copy-code.html %}
26 | ```python
27 | {% include_relative tricky-basic.py %}
28 | ```
29 |
30 | The code for Tricky Playing Soccer is in `tricky-playing-soccer.py` as follows:
31 |
32 | {% include copy-code.html %}
33 | ```python
34 | {% include_relative tricky-playing-soccer.py %}
35 | ```
36 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/tricky/tricky-basic.py:
--------------------------------------------------------------------------------
1 | """
2 | This program is for Tricky's Intro dance.
3 |
4 | Follow the corresponding building instructions in the LEGO® MINDSTORMS®
5 | Robot Inventor App.
6 |
7 | Trigger Tricky to dance by placing something near its Distance Sensor.
8 | """
9 |
10 | from pybricks.pupdevices import Motor, UltrasonicSensor
11 | from pybricks.parameters import Direction, Port
12 | from pybricks.robotics import DriveBase
13 | from pybricks.tools import wait
14 |
15 |
16 | # Configure the Drive Base and the Distance Sensor.
17 | drive_base = DriveBase(left_motor=Motor(Port.A, Direction.COUNTERCLOCKWISE),
18 | right_motor=Motor(Port.B),
19 | wheel_diameter=44,
20 | axle_track=88)
21 |
22 | distance_sensor = UltrasonicSensor(Port.D)
23 |
24 |
25 | # Turn the Distance Sensor lights off and on.
26 | distance_sensor.lights.off()
27 | wait(1000)
28 | distance_sensor.lights.on(100)
29 |
30 | # Tricky begins dancing/turning whenever the Distance Sensor detects
31 | # something closer than 10 cm (100 mm).
32 | while True:
33 | if distance_sensor.distance() < 100:
34 | drive_base.turn(360)
35 | drive_base.turn(-360)
36 | wait(10)
37 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/main-models/tricky/tricky.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/main-models/tricky/tricky.jpeg
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/balancer/README.md:
--------------------------------------------------------------------------------
1 | # LEGO® MINDSTORMS® Robot Inventor balancing robot
2 |
3 | These programs require Pybricks v3.0 firmware installed on the Inventor Hub.
4 |
5 | Building instructions can be found at: TODO.
6 |
7 | Check out a video of the robot in action [here](https://www.youtube.com/watch?v=muVCJEmVa_M)
8 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/balancer/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import InventorHub
2 | from pybricks.pupdevices import Motor, ColorSensor
3 | from pybricks.parameters import Port, Direction
4 | from pybricks.tools import wait, StopWatch
5 | from pybricks.geometry import Axis
6 |
7 | # Initialize motors.
8 | left = Motor(Port.C, Direction.COUNTERCLOCKWISE)
9 | right = Motor(Port.D)
10 | left.reset_angle(0)
11 | right.reset_angle(0)
12 |
13 | # Initialize hub and color sensor.
14 | # You can also use the TechnicHub and/or the ColorDistanceSensor
15 | # instead.
16 | hub = InventorHub()
17 | sensor = ColorSensor(Port.A)
18 |
19 | # Initialize position buffer for speed calculation.
20 | DT = 5
21 | window = int(300 / DT)
22 | buf = [0] * window
23 | idx = 0
24 | angle = 0
25 | DRIVE_SPEED = 300
26 | PAUSE = 5000
27 |
28 | # Timer to generate reference position.
29 | watch = StopWatch()
30 |
31 | while True:
32 | # Get angular rate and estimated angle.
33 | rate = hub.imu.angular_velocity(Axis.Y)
34 | angle += rate * DT / 1000
35 |
36 | # Get motor position.
37 | position = (left.angle() + right.angle()) / 2
38 |
39 | # Calculate motor speed.
40 | speed = (position - buf[idx]) / (window * DT) * 1000
41 | buf[idx] = position
42 | idx = (idx + 1) % window
43 |
44 | # Calculate reference position, which just grows linearly with
45 | # time.
46 | reference = -max(watch.time() - PAUSE, 0) / 1000 * DRIVE_SPEED
47 |
48 | # Calculate duty cycle.
49 | diff = position - reference
50 | duty = 0.018 * rate + 19 * angle + 0.45 * diff + 0.16 * speed
51 |
52 | # Account for battery level and type.
53 | duty *= 7200 / hub.battery.voltage()
54 |
55 | # Calculate steering.
56 | reflection = sensor.reflection()
57 | steering = (reflection - 28) * 0.6
58 |
59 | # Apply duty cycle for balancing and steering.
60 | left.dc(duty + steering)
61 | right.dc(duty - steering)
62 |
63 | # Wait some time.
64 | wait(DT)
65 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/block-flipper/block-flipper.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/other-models/block-flipper/block-flipper.JPG
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/block-flipper/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Fast Block Flipper"
3 | maintainer:
4 | user: "davecparker"
5 | name: "Dave Parker"
6 | image:
7 | local: "block-flipper.JPG"
8 | video:
9 | youtube: "IBtZhiKN9qI"
10 | description:
11 | "A Four-motor robot that quickly moves and flips blocks"
12 | building_instructions:
13 | external: https://www.onekitprojects.com/51515/4-motor-arm
14 | code: "#program"
15 | ---
16 |
17 | ## Description
18 |
19 | This robot arm has four motors to allow it to grab, lift, flip, and move blocks
20 | between the three small raised platforms. The program uses some of the advanced
21 | motor control APIs to control all four motors at the same time and get fast
22 | and accurate motion.
23 |
24 | ## Instructions
25 |
26 | This program controls the 4-Motor Arm autonomously, so you don't have to build
27 | the hand controller. You can just attach the hub to the base as shown.
28 |
29 | Start with the two blocks on the outside (left and right) platforms, and the arm
30 | near the middle between them.
31 |
32 | ## Program
33 |
34 | {% include copy-code.html %}
35 | ```python
36 | {% include_relative block-flipper.py %}
37 | ```
38 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Other Fan Creations"
3 | number: 51515
4 | image:
5 | local: "steerbot/steerbot.jpg"
6 | layout: set
7 | description: "Add set description"
8 | ---
9 |
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/mini-loader/mini-loader.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/other-models/mini-loader/mini-loader.JPG
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/quick-reference/Quick_Ref.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/other-models/quick-reference/Quick_Ref.JPG
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/steerbot/steerbot-instructions.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/other-models/steerbot/steerbot-instructions.pdf
--------------------------------------------------------------------------------
/sets/mindstorms-robot-inventor/other-models/steerbot/steerbot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/mindstorms-robot-inventor/other-models/steerbot/steerbot.jpg
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/cnc_machine/README.md:
--------------------------------------------------------------------------------
1 | # Example LEGO® SPIKE™ Prime programs for CNC Machine
2 |
3 | These programs require PyBricks v3 firmware installed on the Prime Hub.
4 |
5 | Building instructions can be found at https://education.lego.com/en-us/product-resources/spike-prime/downloads/building-instructions.
6 |
7 | The playing instructions for each robot variant are in the docstrings of the corresponding file.
8 |
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/cnc_machine/basic_cnc_machine.py:
--------------------------------------------------------------------------------
1 | """
2 | This program is for CNC Machine
3 | (in the "Invention Squad: Broken" lesson unit).
4 |
5 | Follow the corresponding building instructions in the LEGO® SPIKE™ Prime App.
6 |
7 | This program will draw a rectangle.
8 | """
9 |
10 | from pybricks.hubs import PrimeHub
11 | from pybricks.pupdevices import Motor
12 | from pybricks.parameters import Port
13 |
14 |
15 | # Configure the Hub, the Force Sensor and the Motor
16 | hub = PrimeHub()
17 | horizontal_motor = Motor(Port.A)
18 | vertical_motor = Motor(Port.C)
19 |
20 | # Draw a rectangle
21 | horizontal_motor.run_angle(speed=1000, rotation_angle=400) # go right
22 | vertical_motor.run_angle(speed=1000, rotation_angle=100) # go down
23 | horizontal_motor.run_angle(speed=1000, rotation_angle=-400) # go left
24 | vertical_motor.run_angle(speed=1000, rotation_angle=-100) # go up
25 |
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/hand-controlled-grabber/hand-controlled-grabber.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/spike-prime/core-set/hand-controlled-grabber/hand-controlled-grabber.png
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/hand-controlled-grabber/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Hand-Controlled Grabber"
3 | maintainer:
4 | user: "TheVinhLuong102"
5 | name: "The Lương-Phạm Family"
6 | image:
7 | local: "hand-controlled-grabber.png"
8 | credit: "LEGO"
9 | video:
10 | youtube: "8uyx5npo4LA"
11 | description:
12 | "Use the Grabber to pick up objects and bring them around! Press the Force Sensor to grab objects, and release the Force Sensor to let go of them."
13 | building_instructions:
14 | external:
15 | - https://education.lego.com/v3/assets/blt293eea581807678a/blt56a81c75560c9a81/5f8802cbf71916144453a493/supercleaup-bi-pdf-book1of3.pdf
16 | - https://education.lego.com/v3/assets/blt293eea581807678a/bltb5e585f94cb4e72b/5f8802e5a302dc0d859a734d/supercleaup-bi-pdf-book2of3.pdf
17 | - https://education.lego.com/v3/assets/blt293eea581807678a/bltb8840f08a6d0362b/5f8802dc2792080f7721405c/supercleaup-bi-pdf-book3of3.pdf
18 | code: "#program"
19 | ---
20 |
21 |
22 | This program is for the Hand-Controlled Grabber in the [Invention Squad: Super Clean-Up](https://education.lego.com/en-us/lessons/prime-invention-squad/super-cleanup) lesson unit.
23 |
24 | ## Program
25 |
26 | {% include copy-code.html %}
27 | ```python
28 | {% include_relative main.py %}
29 | ```
30 |
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/hand-controlled-grabber/main.py:
--------------------------------------------------------------------------------
1 | # Hand-Controlled Grabber:
2 | # press the Force Sensor to grab objects,
3 | # and release the Force Sensor to let go.
4 |
5 |
6 | from pybricks.hubs import PrimeHub
7 | from pybricks.pupdevices import ForceSensor, Motor
8 | from pybricks.parameters import Port
9 |
10 |
11 | # Configure the Hub, the Force Sensor and the Motor
12 | hub = PrimeHub()
13 | force_sensor = ForceSensor(Port.E)
14 | motor = Motor(Port.A)
15 |
16 |
17 | while True:
18 | # Grab when the Force Sensor is pressed
19 | if force_sensor.pressed():
20 | motor.run(speed=-1000)
21 |
22 | # else let go
23 | else:
24 | motor.run_until_stalled(speed=1000)
25 |
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "SPIKE Prime Core Set"
3 | number: 45678
4 | image:
5 | local: "spike-prime-core.jpg"
6 | layout: set
7 | description: "Add set description"
8 | ---
9 |
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/kiki_dog/README.md:
--------------------------------------------------------------------------------
1 | # Example LEGO® SPIKE™ Prime programs for Kiki the Dog
2 |
3 | These programs require PyBricks v3 firmware installed on the Prime Hub.
4 |
5 | Building instructions can be found at https://education.lego.com/en-us/product-resources/spike-prime/downloads/building-instructions.
6 |
7 | The playing instructions for each robot variant are in the docstrings of the corresponding file.
8 |
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/kiki_dog/kiki_seeing_colors.py:
--------------------------------------------------------------------------------
1 | """
2 | This program is for Kiki the Dog.
3 |
4 | Follow the corresponding building instructions in the LEGO® SPIKE™ Prime App.
5 |
6 | Kiki shall respond to the blue, yellow or green objects by displaying something
7 | on the Hub's screen.
8 | """
9 |
10 | from pybricks.hubs import PrimeHub
11 | from pybricks.pupdevices import ColorSensor
12 | from pybricks.parameters import Color, Icon, Port
13 |
14 |
15 | # Configure the Hub and the Color Sensor
16 | hub = PrimeHub()
17 | color_sensor = ColorSensor(Port.B)
18 |
19 |
20 | # Kiki walks around and sees things
21 | while True:
22 | # if he sees blue, he thinks it's the sky above
23 | if color_sensor.color() == Color.BLUE:
24 | hub.display.image([
25 | [100, 100, 100, 100, 100],
26 | [0, 0, 0, 0, 0],
27 | [0, 0, 0, 0, 0],
28 | [0, 0, 0, 0, 0],
29 | [0, 0, 0, 0, 0]
30 | ])
31 |
32 | # if he sees yellow, he thinks it's a house
33 | elif color_sensor.color() == Color.YELLOW:
34 | hub.display.image(Icon.UP)
35 |
36 | # if he sees green, he thinks it's the grass below
37 | elif color_sensor.color() == Color.GREEN:
38 | hub.display.image([
39 | [0, 0, 0, 0, 0],
40 | [0, 0, 0, 0, 0],
41 | [0, 0, 0, 0, 0],
42 | [0, 0, 0, 0, 0],
43 | [100, 100, 100, 100, 100]
44 | ])
45 |
46 | else:
47 | hub.display.off()
48 |
--------------------------------------------------------------------------------
/sets/spike-prime/core-set/spike-prime-core.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/spike-prime/core-set/spike-prime-core.jpg
--------------------------------------------------------------------------------
/sets/spike-prime/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "SPIKE Prime"
3 | layout: theme
4 | description: "Theme description"
5 | ---
6 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/42099-off-roader.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42099-off-roader/42099-off-roader.jpg
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/driving/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Autonomous Driving"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "truck.jpg"
8 | description:
9 | "This project shows how to make the car drive and steer. Use it as a
10 | starting point for your own programs."
11 | building_instructions:
12 | external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6314518.pdf
13 | code: "#basic-driving-and-steering"
14 | ---
15 |
16 | # Basic driving and steering
17 |
18 | This program centers the steering motor, and defines a function called
19 | ``drive`` which can be used to control the vehicle. Further details
20 | are given as comments in the program.
21 |
22 | {% include copy-code.html %}
23 | ```python
24 | {% include_relative main.py %}
25 | ```
26 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/driving/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor, ColorDistanceSensor
2 | from pybricks.parameters import Port, Direction, Stop
3 | from pybricks.tools import wait
4 |
5 | # Initialize the motors
6 | steer = Motor(Port.C)
7 |
8 | # Initialize the motors with increased smoothness profile.
9 | front = Motor(Port.A, Direction.COUNTERCLOCKWISE, profile=360)
10 | rear = Motor(Port.B, Direction.COUNTERCLOCKWISE, profile=360)
11 |
12 | # Lower the acceleration so the car starts and stops realistically.
13 | front.control.limits(acceleration=1000)
14 | rear.control.limits(acceleration=1000)
15 |
16 | # Find the steering endpoint on the left and right. The difference
17 | # between them is the total angle it takes to go from left to right.
18 | # The middle is in between.
19 | left_end = steer.run_until_stalled(-200, then=Stop.HOLD)
20 | right_end = steer.run_until_stalled(200, then=Stop.HOLD)
21 |
22 | # We are now at the right limit. We reset the motor angle to the
23 | # limit value, so that the angle is 0 when the steering mechanism is
24 | # centered.
25 | limit = (right_end - left_end) // 2
26 | steer.reset_angle(limit)
27 | steer.run_target(speed=200, target_angle=0, then=Stop.COAST)
28 |
29 |
30 | # Given a motor speed (deg/s) and a steering motor angle (deg), this
31 | # function makes the car move at the desired speed and turn angle.
32 | # The car keeps moving until you give another drive command.
33 | def drive(drive_motor_speed, steer_angle):
34 | # Start running the drive motors
35 | front.run(drive_motor_speed)
36 | rear.run(drive_motor_speed)
37 |
38 | # Limit the steering value for safety, and then start the steer
39 | # motor.
40 | limited_angle = max(-limit, min(steer_angle, limit))
41 | steer.run_target(200, limited_angle, wait=False)
42 |
43 |
44 | # Drive forward for 5 seconds.
45 | drive(800, 0)
46 | wait(5000)
47 |
48 | # Drive backward for 5 seconds.
49 | drive(-800, 0)
50 | wait(5000)
51 |
52 | # Drive forward to the right for 5 seconds.
53 | drive(800, 90)
54 | wait(5000)
55 |
56 | # Drive backward to the left for 5 seconds.
57 | drive(-800, -90)
58 | wait(5000)
59 |
60 | # Stop smoothly and center the steer.
61 | drive(0, 0)
62 | wait(2000)
63 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/driving/truck.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42099-off-roader/driving/truck.jpg
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "4X4 X-treme Off-Roader"
3 | number: 42099
4 | image:
5 | local: "42099-off-roader.jpg"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Add set description"
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/keyboard-remote/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Keyboard Remote Control"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "keyboard-remote-truck.jpg"
8 | description:
9 | "This project shows how you can control the truck with your keyboard."
10 | building_instructions:
11 | external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6314518.pdf
12 | code: "#the-remote-control-program"
13 | ---
14 |
15 | # How it works
16 |
17 | Your MicroPython programs can produce *output* using the `print` command, but
18 | it can also read *input*. You can learn more about this
19 | in [this tutorial](../../../../tutorials/wireless/hub-to-device/pc-keyboard/).
20 |
21 |
22 | # The remote control program
23 |
24 | This program combines the keyboard example linked above with
25 | the [basic driving program](../driving). This allows you to control the
26 | truck using the numeric keys on your keyboard. If your keyboard does not have
27 | separate numeric keys, just adapt the program to use other keys.
28 |
29 | {% include copy-code.html %}
30 | ```python
31 | {% include_relative main.py %}
32 | ```
33 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/keyboard-remote/keyboard-remote-truck.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42099-off-roader/keyboard-remote/keyboard-remote-truck.jpg
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/keyboard-remote/remote.py:
--------------------------------------------------------------------------------
1 | # Import required MicroPython libraries.
2 | from usys import stdin
3 | from uselect import poll
4 |
5 | # Register the standard input so we can read keyboard presses.
6 | keyboard = poll()
7 | keyboard.register(stdin)
8 |
9 | while True:
10 | # Check if a key has been pressed.
11 | if keyboard.poll(0):
12 |
13 | # Read the key and print it.
14 | key = stdin.read(1)
15 | print("You pressed:", key)
16 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/keyboard-remote/terminalwindow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42099-off-roader/keyboard-remote/terminalwindow.png
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/obstacle-avoidance/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Obstacle Avoidance"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "obstacle-avoidance.jpg"
8 | description:
9 | "Make the truck drive around autonomously using sensors."
10 | building_instructions:
11 | external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6314518.pdf
12 | code: "#main-program"
13 | ---
14 |
15 | # Selecting a sensor
16 | This project will work with any sensor that can measure distance.
17 |
18 | You can use
19 | the [Color and Distance sensor](https://docs.pybricks.com/en/latest/pupdevices/colordistancesensor.html)
20 | as in this example, but you can also use the
21 | [Ultrasonic Sensor](https://docs.pybricks.com/en/latest/pupdevices/ultrasonicsensor.html)
22 | or the
23 | [Infrared Sensor](https://docs.pybricks.com/en/latest/pupdevices/infraredsensor.html).
24 | Mount the sensor somewhere on the front of your truck.
25 |
26 | # Main program
27 |
28 | This program builds on the basic [driving example](../driving). It makes the
29 | truck back up and turn when it detects an obstacle.
30 |
31 | {% include copy-code.html %}
32 | ```python
33 | {% include_relative main.py %}
34 | ```
35 |
36 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/obstacle-avoidance/obstacle-avoidance.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42099-off-roader/obstacle-avoidance/obstacle-avoidance.jpg
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/powered-up-remote/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Powered Up Remote Control"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "powered-up-remote-truck.jpg"
8 | description:
9 | "Control LEGO Technic vehicles with the Powered Up Remote."
10 | video:
11 | youtube: "kN47P6mksj4"
12 | building_instructions:
13 | external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6314518.pdf
14 | code: "#block-program"
15 | ---
16 |
17 | # Block Program
18 |
19 | You can easily code this with the new block coding feature. Just drag and drop
20 | the blocks as shown below.
21 |
22 | 
23 |
24 | # Python program
25 |
26 | This program expands the [basic driving program](../driving) with the Powered
27 | Up Remote.
28 |
29 | {% include copy-code.html %}
30 | ```python
31 | {% include_relative main.py %}
32 | ```
33 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/powered-up-remote/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor, Remote
2 | from pybricks.parameters import Port, Direction, Stop, Button
3 | from pybricks.tools import wait
4 |
5 | # Initialize the motors.
6 | steer = Motor(Port.C)
7 |
8 | # Initialize the motors with increased smoothness profile.
9 | front = Motor(Port.A, Direction.COUNTERCLOCKWISE, profile=360)
10 | rear = Motor(Port.B, Direction.COUNTERCLOCKWISE, profile=360)
11 |
12 | # Lower the acceleration so the car starts and stops realistically.
13 | front.control.limits(acceleration=1000)
14 | rear.control.limits(acceleration=1000)
15 |
16 | # Connect to the remote.
17 | remote = Remote()
18 |
19 | # Find the steering endpoint on the left and right.
20 | # The middle is in between.
21 | left_end = steer.run_until_stalled(-200, then=Stop.HOLD)
22 | right_end = steer.run_until_stalled(200, then=Stop.HOLD)
23 |
24 | # We are now at the right. Reset this angle to be half the difference.
25 | # That puts zero in the middle.
26 | steer.reset_angle((right_end - left_end) / 2)
27 | steer.run_target(speed=200, target_angle=0, wait=False)
28 |
29 | # Now we can start driving!
30 | while True:
31 | # Check which buttons are pressed.
32 | pressed = remote.buttons.pressed()
33 |
34 | # Choose the steer angle based on the right controls.
35 | steer_angle = 0
36 | if Button.RIGHT_MINUS in pressed:
37 | steer_angle -= 75
38 | if Button.RIGHT_PLUS in pressed:
39 | steer_angle += 75
40 |
41 | # Steer to the selected angle.
42 | steer.run_target(500, steer_angle, wait=False)
43 |
44 | # Choose the drive speed based on the left controls.
45 | drive_speed = 0
46 | if Button.LEFT_PLUS in pressed:
47 | drive_speed += 1000
48 | if Button.LEFT_MINUS in pressed:
49 | drive_speed -= 1000
50 |
51 | # Apply the selected speed.
52 | front.run(drive_speed)
53 | rear.run(drive_speed)
54 |
55 | # Wait.
56 | wait(10)
57 |
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/powered-up-remote/off-roader-blocks-screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42099-off-roader/powered-up-remote/off-roader-blocks-screenshot.png
--------------------------------------------------------------------------------
/sets/technic/42099-off-roader/powered-up-remote/powered-up-remote-truck.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42099-off-roader/powered-up-remote/powered-up-remote-truck.jpg
--------------------------------------------------------------------------------
/sets/technic/42109_top_gear_rally_car/keyboard_remote/README.md:
--------------------------------------------------------------------------------
1 | Keyboard Remote
2 |
3 | This program demonstrates how to use experimental 'getchar' (similar to 'input' but non-blocking).
4 | The easiest way is running the program through the Pybricks IDE and use the I/O window,
5 | pressing Q/A/O/P/R keys to control the car:
6 |
7 | Q - move forward
8 | A - move backwards
9 | O - turn left
10 | P - turn right
11 | R - reset steering (zero also works)
12 |
13 | each time 'O' or 'P' is pressed the steering is increased a bit until the maximum is reached. 'R' or '0' resets the steering.
14 |
15 | You can tweak these two parameters for a better driving experience:
16 |
17 | TIME_DRIVE
18 |
19 | time in ms that the car moves forward or backward each time a 'Q' or 'A' is pressed
20 | (smaller values will slow it down but it will react faster)
21 |
22 | STEP_STEER
23 |
24 | angle in degrees that is increased/decreased to the current steering angle each time 'O' or 'P' is pressed
25 |
26 | Pressing 'R' or '0' resets the steering angle. Perhaps you want to pre-define some steering values and use
27 | keys like '1' or '2' for turning the weels immediately to those values instead of increasing by steps?
28 |
29 | For advanced users, you can replace the keyboard by an external program that connects to the hub through the Nordic UART Service
30 | and sends the same key codes.
31 |
--------------------------------------------------------------------------------
/sets/technic/42109_top_gear_rally_car/keyboard_remote/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import TechnicHub
2 | from pybricks.pupdevices import Motor
3 | from pybricks.parameters import Port, Stop
4 | from pybricks.tools import wait
5 | from pybricks.experimental import getchar
6 |
7 | hub = TechnicHub()
8 |
9 | drive = Motor(Port.D)
10 | steer = Motor(Port.B)
11 |
12 | SPEED_DRIVE = 100
13 | TIME_DRIVE = 30
14 | STEP_STEER = 15
15 | SPEED_STEER = 720
16 | MAX_STEER = 75
17 |
18 | steer.reset_angle()
19 | steer.run_target(SPEED_STEER, 0, then=Stop.BRAKE)
20 |
21 | while True:
22 | c = getchar()
23 | if c == ord('q'):
24 | drive.dc(SPEED_DRIVE)
25 | wait(TIME_DRIVE)
26 | elif c == ord('a'):
27 | drive.dc(-SPEED_DRIVE)
28 | wait(TIME_DRIVE)
29 | elif c == ord('o'):
30 | if steer.angle() > -MAX_STEER:
31 | steer.run_angle(SPEED_STEER, -STEP_STEER, then=Stop.BRAKE)
32 | elif c == ord('p'):
33 | if steer.angle() < MAX_STEER:
34 | steer.run_angle(SPEED_STEER, STEP_STEER, then=Stop.BRAKE)
35 | elif c == ord('r') or c == ord('0'):
36 | steer.run_target(SPEED_STEER, 0, then=Stop.BRAKE)
37 | else:
38 | drive.stop()
39 |
--------------------------------------------------------------------------------
/sets/technic/42114-volvo-articulated-hauler/42114-volvo-articulated-hauler.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42114-volvo-articulated-hauler/42114-volvo-articulated-hauler.jpg
--------------------------------------------------------------------------------
/sets/technic/42114-volvo-articulated-hauler/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "6x6 Volvo Articulated Hauler"
3 | number: 42114
4 | image:
5 | local: "42114-volvo-articulated-hauler.jpg"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Add set description"
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/technic/42114-volvo-articulated-hauler/powered-up-remote/42114_88010.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42114-volvo-articulated-hauler/powered-up-remote/42114_88010.jpg
--------------------------------------------------------------------------------
/sets/technic/42114-volvo-articulated-hauler/powered-up-remote/remote_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42114-volvo-articulated-hauler/powered-up-remote/remote_description.png
--------------------------------------------------------------------------------
/sets/technic/42124-off-road-buggy/42124-off-road-buggy.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42124-off-road-buggy/42124-off-road-buggy.jpg
--------------------------------------------------------------------------------
/sets/technic/42124-off-road-buggy/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Off-Road Buggy"
3 | number: 42124
4 | image:
5 | local: "42124-off-road-buggy.jpg"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Add set description"
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/technic/42124-off-road-buggy/powered-up-remote/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Powered Up Remote Control"
3 | maintainer:
4 | user: "JorgePe"
5 | name: "Jorge Pereira"
6 | image:
7 | local: "powered-up-remote-buggy.jpg"
8 | description:
9 | "Control the Technic Off-Road Buggy with the Powered Up Remote."
10 | video:
11 | youtube: 6Urq0aX2jR4
12 | building_instructions:
13 | external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6351188.pdf
14 | code: "#program"
15 | ---
16 |
17 | In this project we'll show you how to control the Technic Off-Road buggy with
18 | the Powered Up remote.
19 |
20 | # Program
21 |
22 | This program is similar to most driving vehicles in the Technic series. Check
23 | out the [Technic X-treme Off-Roader](../../42099-off-roader) examples for
24 | additional tips and tricks.
25 |
26 | When the program starts, it connects to your remote and the steering mechanism
27 | is calibrated. Then you are ready to drive.
28 |
29 | The left channel controls the steering and right channel drives the car.
30 |
31 | {% include copy-code.html %}
32 | ```python
33 | {% include_relative main.py %}
34 | ```
35 |
--------------------------------------------------------------------------------
/sets/technic/42124-off-road-buggy/powered-up-remote/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor, Remote
2 | from pybricks.parameters import Port, Direction, Stop, Button
3 | from pybricks.tools import wait
4 |
5 | # Initialize the motors.
6 | steer = Motor(Port.B)
7 | front = Motor(Port.A, Direction.COUNTERCLOCKWISE)
8 |
9 | # Lower the acceleration so the car starts and stops realistically.
10 | front.control.limits(acceleration=1000)
11 |
12 | # Connect to the remote.
13 | remote = Remote()
14 |
15 | # Find the steering endpoint on the left and right.
16 | # The middle is in between.
17 | left_end = steer.run_until_stalled(-200, then=Stop.HOLD)
18 | right_end = steer.run_until_stalled(200, then=Stop.HOLD)
19 |
20 | # We are now at the right. Reset this angle to be half the difference.
21 | # That puts zero in the middle.
22 | steer.reset_angle((right_end - left_end) / 2)
23 | steer.run_target(speed=200, target_angle=0, wait=False)
24 |
25 | # Now we can start driving!
26 | while True:
27 | # Check which buttons are pressed.
28 | pressed = remote.buttons.pressed()
29 |
30 | # Choose the steer angle based on the right controls.
31 | steer_angle = 0
32 | if Button.RIGHT_MINUS in pressed:
33 | steer_angle -= 75
34 | if Button.RIGHT_PLUS in pressed:
35 | steer_angle += 75
36 |
37 | # Steer to the selected angle.
38 | steer.run_target(500, steer_angle, wait=False)
39 |
40 | # Choose the drive speed based on the left controls.
41 | drive_speed = 0
42 | if Button.LEFT_PLUS in pressed:
43 | drive_speed += 1000
44 | if Button.LEFT_MINUS in pressed:
45 | drive_speed -= 1000
46 |
47 | # Apply the selected speed.
48 | front.run(drive_speed)
49 |
50 | # Wait.
51 | wait(10)
52 |
--------------------------------------------------------------------------------
/sets/technic/42124-off-road-buggy/powered-up-remote/powered-up-remote-buggy.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42124-off-road-buggy/powered-up-remote/powered-up-remote-buggy.jpg
--------------------------------------------------------------------------------
/sets/technic/42129-mercedes-benz-zetros/42129-mercedes-benz-zetros.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42129-mercedes-benz-zetros/42129-mercedes-benz-zetros.jpg
--------------------------------------------------------------------------------
/sets/technic/42129-mercedes-benz-zetros/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "4x4 Mercedes-Benz Zetros Trial Truck"
3 | number: 42129
4 | image:
5 | local: "42129-mercedes-benz-zetros.jpg"
6 | credit: "Jim van Gulik"
7 | layout: set
8 | description: "Add set description"
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/technic/42129-mercedes-benz-zetros/powered-up-remote/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Powered Up Remote Control"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "powered-up-remote-lock.jpg"
8 | description:
9 | "Control the Zetros truck with the Powered Up Remote!"
10 | video:
11 | youtube: "-YuvEUQPGnM"
12 | building_instructions:
13 | external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6381993.pdf
14 | code: "#program"
15 | ---
16 |
17 |
18 | # Program
19 |
20 | This program lets you drive the truck around using the Powered Up remote
21 | control. Use the center button to toggle the differential lock.
22 |
23 | {% include copy-code.html %}
24 | ```python
25 | {% include_relative main.py %}
26 | ```
27 |
28 | # Set details
29 |
30 | For more details about this set, check out Jim van Gulik's review over
31 | at [Eurobricks](https://www.eurobricks.com/forum/index.php?/forums/topic/186660-review-42129-4x4-mercedes-benz-zetros-trial-truck/).
32 |
--------------------------------------------------------------------------------
/sets/technic/42129-mercedes-benz-zetros/powered-up-remote/powered-up-remote-lock.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42129-mercedes-benz-zetros/powered-up-remote/powered-up-remote-lock.jpg
--------------------------------------------------------------------------------
/sets/technic/42131-cat-bulldozer/42131-cat-bulldozer.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42131-cat-bulldozer/42131-cat-bulldozer.jpg
--------------------------------------------------------------------------------
/sets/technic/42131-cat-bulldozer/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Cat® D11 Bulldozer"
3 | number: 42131
4 | image:
5 | local: "42131-cat-bulldozer.jpg"
6 | layout: set
7 | description: "Add set description"
8 | ---
9 |
--------------------------------------------------------------------------------
/sets/technic/42131-cat-bulldozer/powered-up-remote/42131-cat-bulldozer-remote.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42131-cat-bulldozer/powered-up-remote/42131-cat-bulldozer-remote.jpg
--------------------------------------------------------------------------------
/sets/technic/42131-cat-bulldozer/powered-up-remote/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Powered Up Remote Control"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "42131-cat-bulldozer-remote.jpg"
8 | description:
9 | "Control the Cat Bulldozer with the Powered Up Remote!"
10 | video:
11 | youtube: "N7OmW-7u8fA"
12 | building_instructions:
13 | external:
14 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6403271.pdf
15 | - https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6403276.pdf
16 | code: "#program"
17 | ---
18 |
19 |
20 | # Program
21 |
22 | This program lets you drive and operate the Cat® D11 Bulldozer using the
23 | Powered Up remote control. No smartphone required!
24 |
25 | When the program begins, it resets the function selector to the zero position,
26 | corresponding to the blade up and down movement. You can select any function
27 | by pressing the *green button* along with one of the gray buttons. This will
28 | change the remote light and switch the function selector as follows:
29 |
30 | * Left + (blue): Moves the blade up and down.
31 | * Left − (red): Tilts the blade back and forth.
32 | * Right + (yellow): Moves the ladder up and down.
33 | * Right − (green): Moves the ripper up and down.
34 |
35 | Once the function is selected, use the red buttons to control the motor that
36 | powers the selected function.
37 |
38 | Use the gray buttons to control the tracks. You can change
39 | the ``DRIVE_ACCELERATION`` value in the code to a lower value to make the
40 | vehicle start and stop driving more gradually. You can also change the speed
41 | by reducing the ``DRIVE_SPEED`` value.
42 |
43 |
44 | {% include copy-code.html %}
45 | ```python
46 | {% include_relative main.py %}
47 | ```
48 | # Credits
49 |
50 | This program was inspired by Pybricks user AVCampos' program first shared on
51 | [Eurobricks](https://www.eurobricks.com/forum/index.php?/forums/topic/182012-42131-cat-d11-bulldozer/&page=46&tab=comments#comment-3455837). Be sure
52 | to check out his code and [video](https://www.youtube.com/watch?v=gy3nFvojZ2o)
53 | for additional inspiration.
54 |
55 | And thanks to Jim van Gulik who lent his bulldozer to the Pybricks team to
56 | make this program and video.
57 |
--------------------------------------------------------------------------------
/sets/technic/42140-app-controlled-transformation-vehicle/42140-app-controlled-transformation-vehicle.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42140-app-controlled-transformation-vehicle/42140-app-controlled-transformation-vehicle.jpg
--------------------------------------------------------------------------------
/sets/technic/42140-app-controlled-transformation-vehicle/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "App-Controlled Transformation Vehicle"
3 | number: 42140
4 | image:
5 | local: "42140-app-controlled-transformation-vehicle.jpg"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Fast-action fun in a model that flips! Build and play with 2 vehicles in 1 model with this App-Controlled Transformation Vehicle that flips when it hits a wall"
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/technic/42140-app-controlled-transformation-vehicle/powered-up-remote/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Powered Up Remote Control"
3 | maintainer:
4 | user: "tensafefrogs"
5 | name: "Geoff Stearns"
6 | image:
7 | local: "./transformation-vehicle-remote.jpg"
8 | credit: "Lasse Deleuran"
9 | video:
10 | youtube: "3Q0I79y1lC0"
11 | description: "Control the Technic App-Controlled Transformation Vechicle with the Powered Up Remote."
12 | code: "#program"
13 | ---
14 |
15 | In this project we'll show you how to control the App-Controlled Transformation Vehicle with the Powered Up remote.
16 |
17 | # Program
18 |
19 | This program enables control of the flip vehicle with the Powered Up Remote.
20 | Check out the video above for an additional program, and more coding ideas.
21 |
22 | {% include copy-code.html %}
23 |
24 | ```python
25 | {% include_relative main.py %}
26 | ```
27 |
28 | Additional program submitted by [@mikeyupol](https://github.com/mikeyupol):
29 |
30 | ```python
31 | {% include_relative main2.py %}
32 | ```
33 |
--------------------------------------------------------------------------------
/sets/technic/42140-app-controlled-transformation-vehicle/powered-up-remote/transformation-vehicle-remote.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42140-app-controlled-transformation-vehicle/powered-up-remote/transformation-vehicle-remote.jpg
--------------------------------------------------------------------------------
/sets/technic/42160-audi-rs-q-e-tron/42160-audi-rs-q-e-tron.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42160-audi-rs-q-e-tron/42160-audi-rs-q-e-tron.webp
--------------------------------------------------------------------------------
/sets/technic/42160-audi-rs-q-e-tron/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Audi RS Q e-tron"
3 | number: 42160
4 | image:
5 | local: "42160-audi-rs-q-e-tron.webp"
6 | credit: "LEGO"
7 | layout: set
8 | description: "Build an Audi rally car. Inspire kids to build a remote-controlled rally car with this LEGO® Technic™ Audi RS Q e-tron model kit."
9 | ---
10 |
--------------------------------------------------------------------------------
/sets/technic/42160-audi-rs-q-e-tron/powered-up-remote/e-tron-remote.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42160-audi-rs-q-e-tron/powered-up-remote/e-tron-remote.jpg
--------------------------------------------------------------------------------
/sets/technic/42160-audi-rs-q-e-tron/powered-up-remote/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Powered Up Remote Control"
3 | maintainer:
4 | user: "tensafefrogs"
5 | name: "Geoff Stearns"
6 | image:
7 | local: "./e-tron-remote.jpg"
8 | credit: "Lasse Deleuran"
9 | video:
10 | youtube: "c0KVNdJlAkc"
11 | description: "Control the Technic Audi RS Q e-tron with the Powered Up Remote."
12 | code: "#program"
13 | building_instructions:
14 | external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6508358.pdf
15 | ---
16 |
17 | In this project we'll show you how to control the Audi RS Q e-tron with the Powered Up remote.
18 |
19 | # Program
20 |
21 | This program enables control of the vehicle with the Powered
22 | Up Remote. Check out the video above for an additional program, and more coding
23 | ideas.
24 |
25 | {% include copy-code.html %}
26 | ```python
27 | {% include_relative main.py %}
28 | ```
29 |
--------------------------------------------------------------------------------
/sets/technic/42160-audi-rs-q-e-tron/xbox-controller/audi-xbox-program.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42160-audi-rs-q-e-tron/xbox-controller/audi-xbox-program.png
--------------------------------------------------------------------------------
/sets/technic/42160-audi-rs-q-e-tron/xbox-controller/audi-xbox.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/sets/technic/42160-audi-rs-q-e-tron/xbox-controller/audi-xbox.jpg
--------------------------------------------------------------------------------
/sets/technic/42160-audi-rs-q-e-tron/xbox-controller/audi_python.py:
--------------------------------------------------------------------------------
1 | from pybricks.iodevices import XboxController
2 | from pybricks.parameters import Direction, Port
3 | from pybricks.pupdevices import Motor
4 | from pybricks.robotics import Car
5 |
6 | # Set up all devices.
7 | front = Motor(Port.A, Direction.CLOCKWISE)
8 | rear = Motor(Port.B, Direction.CLOCKWISE)
9 | steer = Motor(Port.D, Direction.CLOCKWISE)
10 | car = Car(steer, [front, rear])
11 | controller = XboxController()
12 |
13 |
14 | # The main program starts here.
15 | while True:
16 |
17 | # Drive using the trigger inputs.
18 | brake, acceleration = controller.triggers()
19 | car.drive_power(acceleration - brake)
20 |
21 | # Steer with the left joystick.
22 | horizontal, vertical = controller.joystick_left()
23 | car.steer(horizontal)
24 |
--------------------------------------------------------------------------------
/sets/technic/42160-audi-rs-q-e-tron/xbox-controller/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Xbox Controller"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "./audi-xbox.jpg"
8 | description: "Control the Technic Audi RS Q e-tron with the Xbox Controller."
9 | code: "#python-program"
10 | building_instructions:
11 | external: https://www.lego.com/cdn/product-assets/product.bi.core.pdf/6508358.pdf
12 | video:
13 | youtube: "fxInp9cutNg"
14 | ---
15 |
16 | In this project we'll show you how to control the Audi RS Q e-tron with the
17 | Xbox Controller, using either block programming or Python.
18 |
19 | Be sure to check out the documentation in the Pybricks app for instructions
20 | to pair the controller with the hub.
21 |
22 | Note: This is brand a new feature. Try it with [Pybricks beta](https://beta.pybricks.com/)!
23 |
24 | # Block Program
25 |
26 | You can easily code this with the new block coding feature. Just drag and drop
27 | the blocks as shown below, or download the ready-made project here. In
28 | Pybricks, just go to the file menu and click the "Import a file" icon to open
29 | it.
30 |
31 | Download block program
32 |
33 | 
34 |
35 | # Python Program
36 |
37 | {% include copy-code.html %}
38 | ```python
39 | {% include_relative audi_python.py %}
40 | ```
41 |
--------------------------------------------------------------------------------
/sets/technic/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Technic"
3 | layout: theme
4 | description: "Theme description"
5 | ---
6 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 |
2 | [flake8]
3 | exclude = .venv/
4 | # allows us to keep font larger on website without horizontal scrolling
5 | max-line-length = 70
6 | ignore = F401
7 |
8 | [doc8]
9 | ignore-path = .venv/,doc/api/build/,pybricks.egg-info/
10 |
--------------------------------------------------------------------------------
/tutorials/dev/dev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/dev/dev.png
--------------------------------------------------------------------------------
/tutorials/dev/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Development tips and tricks"
3 | layout: theme
4 | description: "Theme description"
5 | ---
6 |
--------------------------------------------------------------------------------
/tutorials/dev/tools/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Installing extra Pybricks tools"
3 | image:
4 | local: "../dev.png"
5 | layout: set
6 | description: "Add set description"
7 | ---
8 |
--------------------------------------------------------------------------------
/tutorials/dev/tools/linux/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Using Pybricks on Linux"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "pybricks-code-linux.png"
8 | description:
9 | "Configure udev and browser tools to use Pybricks."
10 | ---
11 |
12 | # Adding udev rules on Linux
13 |
14 | By default, Linux does not allow the use of unknown USB devices, so you need to add `udev` rules for your hubs. Pybricks provides a couple of ways to do this.
15 |
16 | If you are using an Ubuntu-based Linux distro, you can install the `pbrick-rules` package from the Pybricks PPA. This method has the advantage of automatic updates.
17 |
18 | {% include copy-code.html %}
19 | ```
20 | sudo add-apt-repository --update ppa:pybricks/ppa
21 | sudo apt install pbrick-rules
22 | ```
23 |
24 | You can alternately install the rules using the `pybricksdev` command line tool:
25 |
26 | {% include copy-code.html %}
27 | ```
28 | pipx run pybricksdev udev | sudo tee /etc/udev/rules.d/99-pybricksdev.rules
29 | ```
30 |
31 | If neither of these options is suitable, you can manually copy [this file](https://github.com/pybricks/pybricksdev/blob/master/pybricksdev/resources/99-pybricksdev.rules) to `/etc/udev/rules.d/99-pybricksdev.rules`.
32 |
33 | After installing the `udev` rules, disconnect any affected devices and plug them back in.
34 |
35 | If this doesn't seem to work, try rebooting.
36 |
37 | # Using Pybricks Code with Chromium
38 |
39 | If you use Chromium as a snap package, you may get an error when you try
40 | to install the firmware on a SPIKE hub or MINDSTORMS Robot Inventor hub via
41 | USB. To resolve this, enable access to USB devices:
42 |
43 | {% include copy-code.html %}
44 | ```
45 | sudo snap connect chromium:raw-usb
46 | ```
47 |
--------------------------------------------------------------------------------
/tutorials/dev/tools/linux/pybricks-code-linux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/dev/tools/linux/pybricks-code-linux.png
--------------------------------------------------------------------------------
/tutorials/dev/tools/vscode/pybricks-vscode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/dev/tools/vscode/pybricks-vscode.png
--------------------------------------------------------------------------------
/tutorials/remix/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Remix"
3 | layout: theme
4 | description: "Ideas with a bit of everything"
5 | ---
6 |
--------------------------------------------------------------------------------
/tutorials/remix/iot/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Internet of Things"
3 | image:
4 | local: "iot.png"
5 | layout: set
6 | description: "LEGO connected to the world wide web."
7 | ---
8 |
--------------------------------------------------------------------------------
/tutorials/remix/iot/iot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/remix/iot/iot.png
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/hub-to-device.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-device/hub-to-device.png
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/hub-to-phone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-device/hub-to-phone.png
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Communicating with non-LEGO devices"
3 | image:
4 | local: "hub-to-device.png"
5 | layout: set
6 | description: "Add set description"
7 | ---
8 |
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/pc-communication/hub-to-pc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-device/pc-communication/hub-to-pc.png
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/pc-communication/main.py:
--------------------------------------------------------------------------------
1 | from pybricks.pupdevices import Motor
2 | from pybricks.parameters import Port
3 | from pybricks.tools import wait
4 |
5 | # Standard MicroPython modules
6 | from usys import stdin, stdout
7 | from uselect import poll
8 |
9 | motor = Motor(Port.A)
10 |
11 | # Optional: Register stdin for polling. This allows
12 | # you to wait for incoming data without blocking.
13 | keyboard = poll()
14 | keyboard.register(stdin)
15 |
16 | while True:
17 |
18 | # Let the remote program know we are ready for a command.
19 | stdout.buffer.write(b"rdy")
20 |
21 | # Optional: Check available input.
22 | while not keyboard.poll(0):
23 | # Optional: Do something here.
24 | wait(10)
25 |
26 | # Read three bytes.
27 | cmd = stdin.buffer.read(3)
28 |
29 | # Decide what to do based on the command.
30 | if cmd == b"fwd":
31 | motor.dc(50)
32 | elif cmd == b"rev":
33 | motor.dc(-50)
34 | elif cmd == b"bye":
35 | break
36 | else:
37 | motor.stop()
38 |
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/pc-keyboard/hub-keyboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-device/pc-keyboard/hub-keyboard.png
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/pc-keyboard/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Control your hub with your keyboard"
3 | maintainer:
4 | user: "pybricks"
5 | name: "The Pybricks Team"
6 | image:
7 | local: "hub-keyboard.png"
8 | description:
9 | "This project shows how you to use keyboard input in your programs."
10 | ---
11 |
12 | # How it works
13 |
14 | Your MicroPython programs can produce *output* using the `print` command, but
15 | it can also read *input*. To enter input, just click on the terminal window
16 | and press some keys.
17 |
18 | 
19 |
20 | You can read keyboard presses using `stdin`, as shown in the example below.
21 | Then you can make your program choose different behaviors based on which key
22 | is pressed.
23 |
24 | {% include copy-code.html %}
25 | ```python
26 | {% include_relative remote.py %}
27 | ```
28 |
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/pc-keyboard/remote.py:
--------------------------------------------------------------------------------
1 | # Import required MicroPython libraries.
2 | from usys import stdin
3 | from uselect import poll
4 |
5 | # Register the standard input so we can read keyboard presses.
6 | keyboard = poll()
7 | keyboard.register(stdin)
8 |
9 | while True:
10 | # Check if a key has been pressed.
11 | if keyboard.poll(0):
12 |
13 | # Read the key and print it.
14 | key = stdin.read(1)
15 | print("You pressed:", key)
16 |
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/pc-keyboard/terminalwindow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-device/pc-keyboard/terminalwindow.png
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-device/wireless.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-device/wireless.png
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-hub/broadcast/remote.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import ThisHub
2 | from pybricks.pupdevices import TiltSensor, ColorLightMatrix
3 | from pybricks.parameters import Port, Color
4 | from pybricks.tools import wait
5 |
6 | # Initialize the hub for sending and receiving.
7 | hub = ThisHub(broadcast_channel=1, observe_channels=[2])
8 |
9 | # Initialize the devices.
10 | lights = ColorLightMatrix(Port.A)
11 | sensor = TiltSensor(Port.B)
12 |
13 | while True:
14 | # Read pitch and roll.
15 | pitch, roll = sensor.tilt()
16 |
17 | # Make small tilt zero.
18 | if abs(pitch) < 5:
19 | pitch = 0
20 | if abs(roll) < 5:
21 | roll = 0
22 |
23 | # Send the data!
24 | hub.ble.broadcast((pitch, roll))
25 |
26 | # Check for distance data.
27 | data = hub.ble.observe(2)
28 |
29 | # If there was distance data, use it to activate the light.
30 | if data is not None and data < 500:
31 | lights.on(Color.RED)
32 | else:
33 | lights.off()
34 |
35 | # Wait some time.
36 | wait(10)
37 |
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-hub/broadcast/vehicle.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import ThisHub
2 | from pybricks.pupdevices import Motor, UltrasonicSensor
3 | from pybricks.parameters import Port, Direction
4 | from pybricks.robotics import DriveBase
5 | from pybricks.tools import wait
6 |
7 | # Initialize the hub for sending and receiving.
8 | hub = ThisHub(broadcast_channel=2, observe_channels=[1])
9 |
10 | # Initialize the drive base.
11 | left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE)
12 | right_motor = Motor(Port.B)
13 | drive_base = DriveBase(
14 | left_motor, right_motor, wheel_diameter=56, axle_track=112
15 | )
16 |
17 | # Initialize the distance sensor.
18 | sensor = UltrasonicSensor(Port.C)
19 |
20 | while True:
21 | # Receive tilt data.
22 | data = hub.ble.observe(1)
23 |
24 | if data is not None:
25 | # If we received it, start driving.
26 | pitch, roll = data
27 | drive_base.drive(speed=pitch * 8, turn_rate=roll * 3)
28 | else:
29 | # If we lost the signal, stop.
30 | drive_base.stop()
31 |
32 | # Send the distance data
33 | hub.ble.broadcast(sensor.distance())
34 |
35 | # Wait some time.
36 | wait(10)
37 |
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-hub/hub-to-hub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-hub/hub-to-hub.png
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-hub/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Hub to hub communication"
3 | image:
4 | local: "hub-to-hub.png"
5 | layout: set
6 | description: "Add set description"
7 | ---
8 |
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-hub/pybricks-to-official-fw/duplo-spike-small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-hub/pybricks-to-official-fw/duplo-spike-small.jpg
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-hub/pybricks-to-official-fw/duplo.py:
--------------------------------------------------------------------------------
1 | from pybricks.iodevices import LWP3Device
2 | from pybricks.parameters import Color
3 | from pybricks.tools import wait
4 |
5 | # Device identifier for the Duplo Hub.
6 | DUPLO_TRAIN_ID = 0x20
7 |
8 | # Mapping that converts colors to LEGO color identifiers.
9 | COLORS = {
10 | Color.NONE: 0,
11 | Color.MAGENTA: 2,
12 | Color.BLUE: 3,
13 | Color.GREEN: 6,
14 | Color.YELLOW: 7,
15 | Color.ORANGE: 8,
16 | Color.RED: 9,
17 | }
18 |
19 | class DuploTrain():
20 | """Class to connect to the Duplo train and send commands to it."""
21 |
22 | def __init__(self):
23 | """Scans for a train, connect, and prepare it to receive commands."""
24 | print("Searching for the train. Make sure it is on.")
25 | self.device = LWP3Device(DUPLO_TRAIN_ID, name=None, timeout=10000)
26 | self.device.write(bytes([0x0a, 0x00, 0x41, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01]))
27 | print("Connected!")
28 | wait(500)
29 |
30 | def choo_choo(self):
31 | """Plays the choo choo sound."""
32 | self.device.write(bytes([0x08, 0x00, 0x81, 0x01, 0x11, 0x51, 0x01, 0x09]))
33 |
34 | def light(self, color):
35 | """Turns on the train light at the requested color."""
36 | if color not in COLORS:
37 | return
38 | self.device.write(bytes([0x08, 0x00, 0x81, 0x11, 0x11, 0x51, 0x00, COLORS[color]]))
39 |
40 | def drive(self, power):
41 | """Drives at a given "power" level between -100 and 100."""
42 | power = max(-100, min(power, 100))
43 | if power < 0:
44 | power += 256
45 | self.device.write(bytes([0x08, 0x00, 0x81, 0x00, 0x01, 0x51, 0x00, power]))
46 |
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-hub/pybricks-to-official-fw/instructions.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/hub-to-hub/pybricks-to-official-fw/instructions.pdf
--------------------------------------------------------------------------------
/tutorials/wireless/hub-to-hub/pybricks-to-official-fw/train_driver.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import EssentialHub
2 | from pybricks.pupdevices import Motor, ColorSensor
3 | from pybricks.parameters import Color, Port
4 | from pybricks.tools import wait
5 |
6 | # This imports the DuploTrain from the duplo.py file.
7 | from duplo import DuploTrain
8 |
9 | # Initialize the hub and devices. You can use any other hub too.
10 | hub = EssentialHub()
11 | dial = Motor(Port.A)
12 | sensor = ColorSensor(Port.B)
13 |
14 | # Connect to the train.
15 | train = DuploTrain()
16 |
17 | # These variables are used to monitor the angle and color state.
18 | last_angle = 0
19 | last_color = Color.BLACK
20 |
21 | while True:
22 | # If the measured color changed, play choo choo
23 | # and set the hub and train light to match.
24 | color = sensor.color()
25 | if last_color != color:
26 | last_color = color
27 | if color != Color.NONE:
28 | train.choo_choo()
29 | hub.light.on(color)
30 | train.light(color)
31 |
32 | # Read the angle and discard low values.
33 | angle = dial.angle()
34 | if abs(angle) < 25:
35 | angle = 0
36 |
37 | # Skip updating on small changes to reduce traffic.
38 | if abs(last_angle - angle) < 10:
39 | wait(10)
40 | continue
41 |
42 | # Send new speed.
43 | last_angle = angle
44 | train.drive(angle)
45 |
--------------------------------------------------------------------------------
/tutorials/wireless/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Wireless Communication"
3 | layout: theme
4 | description: "Theme description"
5 | ---
6 |
--------------------------------------------------------------------------------
/tutorials/wireless/remote-control/button-basics/RC_Tutorial.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import TechnicHub # change hub type as necessary
2 | from pybricks.pupdevices import Motor, Remote
3 | from pybricks.parameters import Button, Color, Port
4 |
5 | # Define the hub object.
6 | # For other hub types, change TechnicHub here and on the line 1 import
7 | hub = TechnicHub()
8 |
9 | # This tutorial uses two motors on ports A and B
10 | left_motor = Motor(Port.A)
11 | right_motor = Motor(Port.B)
12 |
13 | # Define the max and current motor speed to use
14 | MAX_SPEED = 720 # deg/sec
15 | speed = MAX_SPEED
16 |
17 | # Try to connect to the remote
18 | hub.light.on(Color.YELLOW) # turn hub light yellow while trying to connect
19 | rc = Remote() # will stop the program if it can't connect
20 | # Set status light on both hub and remote to green to indicate connection
21 | hub.light.on(Color.GREEN)
22 | rc.light.on(Color.GREEN)
23 |
24 | # Get the set of buttons on the remote that start out pressed
25 | pressed = rc.buttons.pressed()
26 |
27 | # The main loop repeatedly tests the remote buttons and reacts (forever)
28 | while True:
29 | # Update the set of buttons that are currently pressed,
30 | # and also remember which ones were pressed the last time we checked.
31 | was_pressed = pressed
32 | pressed = rc.buttons.pressed()
33 |
34 | # 1. Press and hold Left Plus to spin the left motor
35 | if Button.LEFT_PLUS in pressed:
36 | left_motor.run(speed)
37 | else:
38 | left_motor.stop()
39 |
40 | # 2. Tap Left Minus to turn the left motor exactly 720 degrees backwards
41 | if Button.LEFT_MINUS in pressed and Button.LEFT_MINUS not in was_pressed:
42 | left_motor.run_angle(speed, -720)
43 |
44 | # 3. Press and hold Right Plus to spin the right motor forward,
45 | # or Right Minus to spin it backward, or neither to stop it.
46 | if Button.RIGHT_PLUS in pressed:
47 | right_motor.run(speed)
48 | elif Button.RIGHT_MINUS in pressed:
49 | right_motor.run(-speed)
50 | else:
51 | right_motor.stop()
52 |
53 | # 4. Press and hold Right Center to reduce the motor speed while doing 1-3
54 | if Button.RIGHT in pressed:
55 | speed = MAX_SPEED / 4
56 | else:
57 | speed = MAX_SPEED
58 |
--------------------------------------------------------------------------------
/tutorials/wireless/remote-control/drive-base/RC_DriveBase.py:
--------------------------------------------------------------------------------
1 | from pybricks.hubs import InventorHub
2 | from pybricks.pupdevices import Motor, Remote
3 | from pybricks.parameters import Button, Color, Direction, Port, Stop
4 | from pybricks.robotics import DriveBase
5 | from pybricks.tools import wait, StopWatch
6 |
7 | # Define objects for a simple two motor rover using a DriveBase
8 | hub = InventorHub()
9 | left_motor = Motor(Port.A, positive_direction=Direction.COUNTERCLOCKWISE)
10 | right_motor = Motor(Port.B, positive_direction=Direction.CLOCKWISE)
11 | drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=96)
12 |
13 | # Speeds and accelerations to use
14 | STRAIGHT_SPEED = 300 # straight driving speed (mm/sec)
15 | TURN_RATE = 150 # turning rate (deg/sec)
16 |
17 | # Connect to the remote
18 | hub.light.on(Color.YELLOW) # turn hub light yellow while trying to connect
19 | rc = Remote() # will stop the program if it can't connect
20 | # Set status light on both hub and remote to green to indicate connection
21 | hub.light.on(Color.GREEN)
22 | rc.light.on(Color.GREEN)
23 |
24 | # The main loop repeatedly tests the remote buttons and reacts
25 | while True:
26 | # Get the set of buttons that are currently pressed,
27 | pressed = rc.buttons.pressed()
28 |
29 | # Determine what straight driving speed to use
30 | if (Button.LEFT_PLUS in pressed):
31 | speed = STRAIGHT_SPEED
32 | elif (Button.LEFT_MINUS in pressed):
33 | speed = -STRAIGHT_SPEED
34 | else:
35 | speed = 0
36 |
37 | # Determine what turn rate to use
38 | if (Button.RIGHT_PLUS in pressed):
39 | turn_rate = TURN_RATE
40 | elif (Button.RIGHT_MINUS in pressed):
41 | turn_rate = -TURN_RATE
42 | else:
43 | turn_rate = 0
44 |
45 | # Update the driving and turning speeds
46 | drive_base.drive(speed, turn_rate)
47 |
48 |
--------------------------------------------------------------------------------
/tutorials/wireless/remote-control/drive-base/drive-base.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/remote-control/drive-base/drive-base.JPG
--------------------------------------------------------------------------------
/tutorials/wireless/remote-control/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "LEGO Remote Control"
3 | image:
4 | local: "lego-remote.jpg"
5 | credit: "LEGO"
6 | layout: set
7 | description: "Using the LEGO Powered Up Remote Control"
8 | ---
9 |
--------------------------------------------------------------------------------
/tutorials/wireless/remote-control/lego-remote.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pybricks/pybricks-projects/faaacce09ffe1d865fd1db241bcacb056234d597/tutorials/wireless/remote-control/lego-remote.jpg
--------------------------------------------------------------------------------
/update_workspaces.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | from os import scandir, path
3 | from json import dump
4 |
5 |
6 | def make_workspace(root):
7 |
8 | # Get list of folder names
9 | names = [d.name for d in scandir(root) if d.is_dir()]
10 | names.sort()
11 |
12 | # Make the workspace dictionary
13 | workspace = {
14 | "folders": [
15 | {
16 | "path": name
17 | }
18 | for name in names
19 | ],
20 | "settings": {
21 | "debug.openDebug": "neverOpen"
22 | }
23 | }
24 |
25 | # Work space name is same as path
26 | workspace_name = root.replace('/', '_').replace('\\', '_')
27 | workspace_name += '.code-workspace'
28 |
29 | # Save workspace
30 | with open(path.join(root, workspace_name), 'w') as f:
31 | dump(workspace, f, indent=4)
32 |
33 |
34 | # Make all the workspaces
35 | roots = (
36 | path.join('sets', 'ev3', 'education_core'),
37 | path.join('sets', 'ev3', 'education_expansion'),
38 | path.join('sets', 'ev3', 'home'),
39 | path.join('sets', 'ev3', 'home_bonus'),
40 | )
41 |
42 | for root in roots:
43 | make_workspace(root)
44 |
--------------------------------------------------------------------------------