Compare commits

...

362 Commits

Author SHA1 Message Date
c7fabfd994 0.1.59 2018-05-31 10:16:04 -07:00
df49475a26 bump pxt-core to 3.18.9, 2018-05-31 10:15:58 -07:00
17d8e61ebc 0.1.58 2018-05-31 10:13:17 -07:00
dbdc1810cd Add copyright text (#667) 2018-05-30 15:42:37 -07:00
d3b7530b17 EV3 Brick terminology (#665)
* reprhased

* EV3 brick => EV3 Brick

* revert a change
2018-05-30 15:42:17 -07:00
e31f4c934f Update README.md 2018-05-29 11:04:22 -07:00
b22ec74f7e Tshoot page edits (#658)
* T-shoot page edits post revert

* Restyle link

* Merge in revert page

* Clarify brick info step

* Keep periods off simple steps this time
2018-05-23 16:25:05 -07:00
cd38f670d2 T shoot page revert (#657)
* T-shoot page edits

* Revert t-shoot page
2018-05-23 12:04:32 -07:00
8fca537251 T-shoot page edits 2018-05-23 11:18:46 -07:00
cf39956e2d Tiny tweak to troubleshooting page 2018-05-23 09:10:47 -07:00
9e3a8ab4ed updated troubleshoot page 2018-05-23 07:50:38 -07:00
022a6765bf removing libs/automation, libs/chassis 2018-05-21 15:19:26 -07:00
1e4edc5109 Patch release (0.1.57) (#655)
Release 0.1.57 with tutorial fix patch
2018-05-18 14:26:13 -07:00
caf273be84 fix line following paragraph 2018-05-18 13:53:59 -07:00
ccba83cfab 0.1.57 2018-05-18 16:32:14 -04:00
8417c6ce57 Bumping pxt-core to 3.13.29 2018-05-18 16:31:36 -04:00
39236fe8b2 Release app 0.1.56 2018-05-18 10:51:16 -04:00
f50aabeec5 Update issue templates 2018-05-17 16:25:35 -07:00
c2167b6405 0.1.56 2018-05-16 06:37:29 -07:00
59dcd1ee72 fix another support link 2018-05-16 06:37:17 -07:00
bf8f73f885 Update favicon as per Lego spec (#650) 2018-05-15 13:40:55 -07:00
a81e3b9f11 Better description for stop all sounds. (#649) 2018-05-15 11:21:24 -07:00
e90b6a7946 0.1.55 2018-05-15 07:41:06 -07:00
7ce6c8b773 updated support with https link 2018-05-15 07:40:54 -07:00
022651b338 removing blurb 2018-05-15 07:38:18 -07:00
8d0bc280a0 Adding prepare card. (#594) 2018-05-14 11:49:06 -07:00
7b61a8fbc3 Releasing patch 0.1.54 (#628) 2018-05-11 18:04:53 -07:00
1d45652ab2 0.1.54 2018-05-11 15:58:11 -07:00
4db9c8bc0a Bump pxt-core to 3.13.28 2018-05-11 15:57:54 -07:00
df99fa1699 adding filename filter 2018-05-10 11:05:16 -07:00
ef218bcc24 0.1.53 2018-05-09 15:02:27 -04:00
99ccbfc348 0.1.52 2018-05-09 13:00:30 -04:00
101306b8f8 Add crowdin project 2018-05-09 12:59:52 -04:00
e167f109b0 0.1.51 2018-05-09 12:39:56 -04:00
e5d78d65cb Add crowdin to build (#591) 2018-05-09 12:39:25 -04:00
b79881ade0 Release 0.1.50 2018-05-07 16:52:57 -07:00
a05d12abdf 0.1.50 2018-05-07 15:13:07 -07:00
6c2cd1a658 Revert beta fix 2018-05-07 15:12:53 -07:00
90204ce58f 0.1.49 2018-05-07 15:07:28 -07:00
d8c4eeeb13 bump pxt-core to 3.12.26, 2018-05-07 15:07:22 -07:00
df6249931d Update download dialog (#589) 2018-05-07 14:59:29 -07:00
de61919fc1 Don't use ```block in tutorials. (#588) 2018-05-07 13:20:10 -07:00
105da90f3f Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-05-07 13:03:26 -07:00
023fc8fe96 typo 2018-05-07 13:03:20 -07:00
442b014233 Release beta (#587) 2018-05-07 12:57:46 -07:00
54681668ad 0.1.48 2018-05-07 12:35:51 -07:00
db1724b9fa moving to .24 2018-05-07 12:29:30 -07:00
7ed5a9bca6 0.1.47 2018-05-07 11:25:04 -07:00
7de61c7254 Remove beta (#586) 2018-05-07 11:24:45 -07:00
df99f18c8d 0.1.46 2018-05-07 11:07:12 -07:00
6d7bd63c3a bump pxt-core to 3.12.23, 2018-05-07 11:07:06 -07:00
9d1f39981d Release electron 0.1.43 2018-05-07 10:01:47 -04:00
e4e87c427d 0.1.45 2018-05-05 07:45:59 -07:00
1fece05e5e bump pxt 2018-05-05 07:37:24 -07:00
186c7e2e3f Small tutorial fixes and FE image updates (#585) 2018-05-04 18:43:29 -07:00
3322119f35 Unplug tutorial intros from step path (#584) 2018-05-04 16:23:53 -07:00
515be621a0 0.1.44 2018-05-04 15:54:10 -07:00
b337f4cf1c bump pxt-core to 3.12.21, 2018-05-04 15:54:04 -07:00
e6e6016bc0 0.1.43 2018-05-04 10:37:55 -07:00
3f23f5afa8 bump pxt-core to 3.12.19, bump pxt-common-packages to 0.22.7, 2018-05-04 10:37:48 -07:00
f0df0222c0 Fixes for High contrast mode as per lego design. Most changes are in PXT. Adding high contrast theme in the simulator (#564) 2018-05-04 10:36:48 -07:00
2a371b9cc6 Release electron v0.1.40 2018-05-04 10:04:39 -04:00
3211999583 0.1.42 2018-05-03 17:07:09 -07:00
b29862d566 update packaglock 2018-05-03 17:04:22 -07:00
b262d944b7 bump pxt-core to 3.12.18, bump pxt-common-packages to 0.22.2, 2018-05-03 17:03:16 -07:00
1b89d08337 Reduce size of tutorial gifs (#562) 2018-05-03 17:02:22 -07:00
6bdae6547a 0.1.41 2018-05-03 15:03:24 -07:00
30a67b729d Align all modules to a minimum height. (#563) 2018-05-03 15:02:13 -07:00
3e2c61e212 0.1.40 2018-05-03 11:59:50 -07:00
7a37dec196 Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-05-03 11:48:19 -07:00
bac792f188 upgrade firmware -> troubleshoot 2018-05-03 11:48:10 -07:00
e4c3fa0e57 Make the light around the color sensor appear bright and not a reflection of the current color detected. (#561) 2018-05-03 08:39:06 -07:00
76f7df7579 Update favicon 2018-05-03 08:06:39 -07:00
d7e671175c 0.1.39 2018-05-03 06:57:18 -07:00
f4b7230a67 remove "pxtrequire" 2018-05-03 06:55:50 -07:00
afe0f9b0f7 updated pxt 2018-05-03 06:54:30 -07:00
23b6edc4bf Release app 0.1.36 2018-05-03 09:22:18 -04:00
13b3c1a194 Attempt to shorten color sensor ambient and reflected blocks by removing detected keyword (#560) 2018-05-02 22:09:04 -07:00
7e58b9b699 Motor angle (#559)
* control angle with slider

* called changed state

* remove logging
2018-05-02 22:04:29 -07:00
08a860bd80 Update tutorial gifs to match new sim inputs (#558) 2018-05-02 17:15:29 -07:00
4a966a73f1 0.1.38 2018-05-02 16:24:41 -07:00
542216000c 0.1.37 2018-05-02 16:24:35 -07:00
b323929f03 Fix color grid on IE. (#556) 2018-05-02 16:23:53 -07:00
1e3647738d Update download dialog. (#555) 2018-05-02 15:15:25 -07:00
838b3f7f9a 0.1.36 2018-05-02 15:07:55 -07:00
0ff2d7866d bump pxt-core to 3.12.16, 2018-05-02 15:07:45 -07:00
4c978d793a 0.1.35 2018-05-02 14:00:27 -07:00
06ca53ae89 Remove unused dependencies 2018-05-02 14:00:08 -07:00
84990d66a9 Update simulator as per latest lego UI design for sensors. Fix full screen layout issues. (#554) 2018-05-02 13:58:59 -07:00
4825172423 Update numbers music icon (from lego) (#553) 2018-05-02 13:55:44 -07:00
b69af383a6 Better mouse event handling (#552)
* Use learnings from touch events in Blockly and apply to the Ev3 sim. Register move and up events on the document rather than the individual element allowing users greater flexibility where they move their mouse once it's down.

* Add mouse leave events
2018-05-02 13:54:06 -07:00
6e1a613798 0.1.34 2018-05-02 12:58:27 -07:00
b5005f3b10 bump pxt-core to 3.12.12, 2018-05-02 12:57:46 -07:00
044b585f24 Release Electron app v0.1.30 2018-05-02 10:13:07 -04:00
94fe26e390 0.1.33 2018-05-01 22:05:57 -07:00
ca832f52db upgrading pxt 2018-05-01 22:05:46 -07:00
6f2fe212df Tutorial updates (#551)
* updated line following, added simulator step

* full screen

* resizing some images
2018-05-01 21:53:28 -07:00
96be357af1 updated package-lock 2018-05-01 16:16:19 -07:00
36df6cfb03 0.1.32 2018-05-01 14:13:09 -04:00
e1095b3d4a Integrating field music icons (#549)
* Use the music icons provided by lego in the music field editor
2018-05-01 14:12:42 -04:00
9257e08f0d 0.1.31 2018-05-01 13:08:38 -04:00
149f256454 bump pxt-core to 3.12.9, 2018-05-01 13:08:33 -04:00
ba00d91bf2 Fixes for the download dialog (className), and update the location of the troubleshoot link. (#548) 2018-05-01 13:08:05 -04:00
764994a633 updates to troubleshoot page 2018-05-01 08:48:02 -07:00
ab85cf2d0a Remove jquery typings (#547) 2018-04-30 16:29:23 -04:00
ce7ecd5121 Update favicons to the lego icon. (#546) 2018-04-30 13:33:56 -04:00
40fb4107cf 0.1.30 2018-04-30 13:08:13 -04:00
9b8816f781 bump pxt-common-packages to 0.21.13, 2018-04-30 13:08:09 -04:00
27756d922e bump pxt-core to 3.12.5, 2018-04-30 13:06:45 -04:00
0b1d7068e9 Changes accompanying the new blockly toolbox (#545) 2018-04-30 13:06:24 -04:00
0a5b4b9329 0.1.29 2018-04-27 10:55:37 -04:00
2da1b3111f Bumping pxt-core to 3.12.4 2018-04-27 10:55:07 -04:00
f600ee270e 0.1.28 2018-04-27 10:53:34 -04:00
7c3d499109 fix dmesg duplicate definition issue (#542) 2018-04-25 16:45:26 -04:00
8ed79e7133 Swap X/y in images (#528)
* Swap X/Y in image encoding

* Fix PNG decoder

* Now really fix png

* reducing deps

* moving png.cpp into ev3

* bumped pxt

* updated shims

* fixing c++ compilation

* updated shims

* Fix pixel order

* update pxt

* Fix C++ image decoding

* Add expanded PNG images

* Generate E1 format images (in libs/ev3 run 'pxt buildsprites images')

* Go back to white background

* Remove PNG support
2018-04-19 12:08:16 -07:00
95ab3be26e Diagram and linking fixes for 'Maker Design Process' (#533) 2018-04-18 13:15:53 -07:00
83700b4e14 Music field editor (#529)
Music fiele editor
2018-04-17 22:16:19 -07:00
989699c620 Update hero banner 2018-04-17 16:26:51 -07:00
e0c80361db Editor feature page override with button images (#521)
* Editor feature page override with button images

* Update the 'about' a bit

* Bold the 'drivename'

* Add a ref to the editor features page in about
2018-04-17 16:10:54 -07:00
67153fccc5 Reduce the use of @boardname@ (#527)
* Reduce the use of @boardname@

* Use literal 'EV3 Brick' string instead

* Use the new 'nickname' form
2018-04-16 16:15:58 -07:00
3c96cfcc0a Change to always show the sensor controls. (#526) 2018-04-16 11:50:12 -07:00
03add213d9 Only using main loader for editor loader, other loaders use standard spinning loader. (#524) 2018-04-16 10:52:39 -07:00
e43837d358 Hide or remove logging (#523)
* Hide or remove logging

* Remote dmsg
2018-04-15 19:36:10 -07:00
be207282e3 Move blockly toolbox css to semantic.css (#522) 2018-04-15 10:29:37 -07:00
d6e4c5a717 Use pxtsemantic which includes only the semantic components we use in PXT. (#520) 2018-04-14 00:55:29 -07:00
5384ec567d split editors (#516)
* spliteditor
2018-04-13 21:46:19 -07:00
6ea8a59f58 Release v0.1.27 (#519)
* Release v0.1.26

* Update index-ref.json
2018-04-13 21:03:43 -07:00
03c6100635 0.1.27 2018-04-13 20:52:51 -07:00
173b5dfd18 0.1.26 2018-04-13 20:06:50 -07:00
c86331b857 0.1.25 2018-04-13 20:06:16 -07:00
43a3942147 bump pxt-core to 3.8.15, 2018-04-13 20:06:09 -07:00
10cc883ef7 Fix serial editor theme. (#517) 2018-04-13 19:59:10 -07:00
2cbb3e05b0 Fix card border radius 2018-04-13 19:15:34 -07:00
eac73932be Release v0.1.24 (#515)
Release ev3
2018-04-13 17:04:27 -07:00
62e8f698a5 0.1.24 2018-04-13 15:53:09 -07:00
d0331720b4 Fix slider gradient bug when loading components from a previous sim run. (#514) 2018-04-13 15:52:38 -07:00
724ac19281 0.1.23 2018-04-13 15:24:28 -07:00
3e193e97bf bump pxt-core to 3.8.14, 2018-04-13 15:24:23 -07:00
23c1789976 Fix IE11 for in bug in motor field (#513)
* Fix IE11 for in bug in motor field

* minor fix
2018-04-13 15:21:41 -07:00
87b08bf6f3 0.1.22 2018-04-13 14:02:04 -07:00
3e534f7329 Update state of the landscape brick view as well to be consistent with the portrait view (main) (#508) 2018-04-13 14:01:37 -07:00
7f8499bb5f Always show the motor value regardless if it's 0. (#509) 2018-04-13 14:01:25 -07:00
4bcde58c0c 0.1.21 2018-04-13 12:37:36 -07:00
dd5df88dea Update test 2018-04-13 14:50:20 -04:00
f35ed0205b 0.1.20 2018-04-13 11:47:55 -07:00
7379c8dfe7 Friday 13th using .13 builfd 2018-04-13 11:37:51 -07:00
574de3a15e bumping pxt 2018-04-13 11:29:00 -07:00
a3c08ddb01 branding fixes 2018-04-13 09:05:34 -07:00
070cc42d36 Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-04-12 15:05:19 -07:00
77aa7b86d8 fixing summary 2018-04-12 15:05:14 -07:00
f912ea6104 0.1.19 2018-04-12 15:01:43 -07:00
b06bc6bc6c bump pxt-core to 3.8.11, 2018-04-12 15:01:38 -07:00
af3189d8b5 removing mindstorms from tutorial names (#496)
* removing mindstorms from tutorial names

* lego feedback

* file name issues

* bring back bang
2018-04-12 14:41:22 -07:00
661157f112 0.1.18 2018-04-12 14:29:52 -07:00
141bc6bddb bump pxt-core to 3.8.10, 2018-04-12 14:29:44 -07:00
bd06fb80f3 Threshold to calibration (#495)
* renaming threshold to calibration

* rename threshold to calibration
2018-04-12 14:25:44 -07:00
2c874570ce Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-04-12 10:33:27 -07:00
08ee2b2017 fixing branding 2018-04-12 10:33:21 -07:00
499d97b07c Update targetconfig.json 2018-04-12 13:26:02 -04:00
32b7400e9e Optimizing Logos. 2018-04-12 00:36:11 -07:00
90717cfc33 Change drive label to EV3 (#494) 2018-04-11 17:20:07 -06:00
bd3b149dcc Tutorial theming (#493)
* Tutorial theming

* no border
2018-04-11 13:22:21 -06:00
fafd3d37da Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-04-11 09:33:01 -07:00
138425c0fb missed renaming 2018-04-11 09:32:54 -07:00
231cd41f7a rename intruder to security (#492) 2018-04-11 10:31:53 -06:00
eb7cd5d97c 0.1.17 2018-04-11 08:59:01 -07:00
a4a9af28a4 Switch to reflected light when calling threshold (#489)
* fix typo

* fixing threshold functions

* switch to reflected mode when calling threshold
2018-04-11 09:58:34 -06:00
6c253182e4 0.1.16 2018-04-11 08:00:47 -07:00
0198be6dda add screen mode to auto clear screen between modes (#486) 2018-04-11 09:00:22 -06:00
57ab6d153d added support links 2018-04-11 08:00:01 -07:00
fd0bd4ef39 update drive name 2018-04-11 07:58:02 -07:00
8b2ae10980 Initial 'troubleshoot' page (#484)
* Initial 'troubleshoot' page

* Define 'driveDisplayName'

* Tutorial name goof

* Add fake label for drive

* And typo

* Add firmware update section

* Add a hint for offline firmware update
2018-04-11 08:57:29 -06:00
4627328bcd Output set Type fix (#487)
* properly send outputsettype info

* fix simulator

* bump pxt

* typo in docs
2018-04-11 08:48:07 -06:00
80989cf4c9 More tutorial typos (#485) 2018-04-11 08:45:44 -06:00
00b193b126 Add 'intruder alert' tutorial (#452)
* Add 'intrduer alert' tutorial

* Use 'detected' option instead of 'near'
2018-04-10 23:43:28 -06:00
e65db0b756 Update dimmer background, refactor top menu background. (#483)
Minor ui changes (dimmer background)
2018-04-10 12:48:00 -07:00
8f211a5c19 Use sort option in FieldImages to sort the options after showing the editor (not before) (#482) 2018-04-10 11:51:08 -07:00
379a6a26be Add large and medium motor speed labels (#480)
* Add large and medium motor speed labels

* Support dual motor labels.
2018-04-10 11:50:58 -07:00
8398c8efdb Dispose correctly of gradient definitions in the control. Attach to port number not id. 2018-04-10 11:49:15 -07:00
f41310e879 Update large motor holes to be transparent (like the real thing) (#476) 2018-04-09 17:27:57 -07:00
82198020de 0.1.15 2018-04-09 17:22:07 -07:00
09d6b728b0 bump pxt-core to 3.8.6, 2018-04-09 17:22:01 -07:00
9147cb98c2 Updates to the download dialog. Fixes #424 (#443)
* Updates to the download dialog. Fixes #424
2018-04-09 17:20:38 -07:00
6d29cd40cb Make both the simulator color picker and the Blockly editor color picker match in shape and the colors as well as order of colors. (#474) 2018-04-09 16:48:57 -07:00
d5b4ec5255 Center align the toggle buttons (#473) 2018-04-09 16:26:46 -07:00
b8286ab0b9 Medium motor resizing (#472) 2018-04-09 16:24:01 -07:00
ac1380ec92 Better screen zoom that makes use of the full width of the simulator. (#471) 2018-04-09 16:21:41 -07:00
a433988929 New motor field editor (#470)
* New motor field editor showing two dropdown, first to select the type and the second to select the port.
2018-04-09 15:59:28 -07:00
d837a515dc Fix brick color not changing to the color red. Fixes 453 (#456) 2018-04-08 03:35:02 -06:00
4be657e84d Remove about from the help menu (#451) 2018-04-06 13:30:14 -07:00
c90f00f6d0 Object near tutorial (#445)
* Add 'Object Near?' tutorial

* Add to SUMMARY

* Fix screen line index

* Redo tutorial

* Paste fail typo
2018-04-06 13:09:27 -07:00
ecc880cf8d Move on start to the top of the list in loops. (#448) 2018-04-06 09:51:54 -07:00
fbb3280bc8 Showimagedelay (#446)
* add delay on "show image"

* removing optional duration
2018-04-05 20:42:03 -07:00
29f081eb03 Remove social share links from footer (#444) 2018-04-05 20:36:02 -07:00
49ab5ec099 Shrink some of the tutorial sentences (#440)
* Shrink some of the tutorial sentences

* Match the less than order for blocks

* Include later tutorials in SUMMARY

* Ditch 'using' in name
2018-04-05 17:32:32 -07:00
5277cc847c removing support for far in ultrasonic (#441)
* removing support for far in ultrasonic

* removing more far
2018-04-05 17:07:14 -07:00
e11b11d19c Add 'red light, green light' tutorial (#436) 2018-04-05 16:02:46 -07:00
57c1ae0f99 Add 'line following' tutorial (#435) 2018-04-05 13:37:24 -07:00
2129601e6a 0.1.14 2018-04-05 11:03:20 -07:00
e1727dc917 update pxt (#433)
* update pxt

* hide image field editors
2018-04-05 10:40:11 -07:00
ecc9319334 Switch the backing of the blocks JS toggle. (#431)
* Switch the backing of the blocks JS toggle.

* Minor changes
2018-04-05 06:48:27 -07:00
81758f2555 What color tutorial (#430)
* Add 'What color' tutorial

* More edits and thumbnail
2018-04-04 22:15:09 -07:00
7825bd1579 Use the correct sig for ultrasonic onEvent doc (#429) 2018-04-04 16:21:00 -07:00
ac81067f82 Tutorial format and macro fixes (#425)
* Tutorial format and macro fixes

* Remove branded names
2018-04-04 15:12:55 -07:00
b1958d77e7 Add 'Touch sensor values` tutorial (#421)
* Add 'Touch sensor values` tutorial

* Edits and thumbnail

* Modify activity to no restart motor
2018-04-04 13:57:40 -07:00
232744520b Remove 'examples' from summary (#423) 2018-04-04 13:57:17 -07:00
ac9ebf6776 Add 'Touch to Run` tutorial (#420)
* Add 'Touch to Run` tutorial

* Edits and thumbnail image
2018-04-03 21:33:53 -07:00
c97098b99e Add 'Run Motors' tutorial (#419)
* Add 'Run Motors' tutorial

* Finish edits and add thumbnail
2018-04-03 20:53:35 -07:00
b39a7f3484 Add 'Mindstorms Music' tutorial (#418)
* Add 'Mindstorms Music' tutorial

* Add image and edits
2018-04-03 19:31:35 -07:00
806f60a419 Add 'What Animal Am I' tutorial (#417) 2018-04-03 17:55:15 -07:00
0bb7295d86 Press button tutorial (#416)
* Add tutorial for 'Make Animation'

* Finish off the tutorial
2018-04-03 16:37:07 -07:00
60bf3df1d8 Show mood tutorial prototype (#414)
* Show mood tutorial prototype

* Missed block styling
2018-04-03 15:45:11 -07:00
b8a3fa345f Include doc stubs for excluded music methods (#411) 2018-04-03 14:39:30 -07:00
ec1ceea138 bump version to 0.1.13 (#407)
* bump version

* Light Condition -> Light

* roll back 0.1.11
2018-04-03 12:03:15 -07:00
b618bfec59 0.1.13 2018-04-03 05:05:32 -07:00
2467b3c4c9 renaming pauseforcolor to pause until color detected (#405)
* renaming pauseforcolor to pause until color detected

* pauseForLight -> pauseUntilLightConditionDetected

* on light changed -> on light condition detected

* fixing docs

* docs tweaks
2018-04-03 05:05:01 -07:00
69194b0b76 Erase on showstring + showports improvements (#402)
* erase line before show string + show ports upgrade

* fixed font size

* fixing console output
2018-04-03 04:30:23 -07:00
3339a7660a moving motor properties to lower group (#403) 2018-04-03 04:30:10 -07:00
9c3be9fe37 Remove duplicate lessons (#391) 2018-04-03 04:11:48 -07:00
c0413aa192 hiding the was pressed block (#401) 2018-04-03 04:10:35 -07:00
6c626f9c98 0.1.12 2018-03-30 15:47:03 -07:00
f95b39cd62 updated shims 2018-03-30 15:46:04 -07:00
bba0af6193 adding defaults to music 2018-03-30 15:45:36 -07:00
a8a92ca806 moving to 0.1.11 2018-03-30 14:51:20 -07:00
6f066e4397 0.1.11 2018-03-30 13:32:37 -07:00
7dd27b3da1 bumping pxt 2018-03-30 13:27:49 -07:00
41514cfa64 0.1.10 2018-03-30 09:56:55 -07:00
53ad94d0ad bump pxt-common-packages to 0.20.30, 2018-03-30 09:56:50 -07:00
220a774238 bump pxt-core to 3.6.2, 2018-03-30 09:48:28 -07:00
7444b28ebb Update monaco editor background 2018-03-30 09:11:13 -07:00
8abc137d60 Add 'showPorts' api doc (#392) 2018-03-29 16:43:17 -07:00
3cad464ea5 Activity category & description fixes (#390) 2018-03-29 15:16:26 -07:00
b6b23314cb 0.1.9 2018-03-29 17:02:56 -04:00
34381ed171 bump pxt-core to 3.6.1, 2018-03-29 17:02:50 -04:00
a627d19ebf Add locales entry to pxtarget (#389)
* Add locales entry to pxtarget

* Remove languages from targetconfig
2018-03-29 17:01:05 -04:00
4cbdd72770 fixed support url 2018-03-28 21:36:53 -07:00
6412d52f99 fixing tacho references 2018-03-28 21:28:15 -07:00
c75bd0b06d 0.1.8 2018-03-28 21:20:56 -07:00
79afed3667 Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-03-28 21:20:54 -07:00
e040407070 bumping pxt 2018-03-28 21:20:35 -07:00
123d41cb64 adding english to language option (#387) 2018-03-28 20:20:16 -07:00
0dc2548d0b Optimize simulator for light mode. (#379)
* Optimize simulator for light mode.

* Add user-select none.
2018-03-28 13:36:52 -07:00
b4b3a24ed2 test release manifest (#381) 2018-03-28 12:31:42 -04:00
ed653e8a37 0.1.7 2018-03-28 09:05:10 -07:00
31f91d4e24 upgrading to latest common packages (#383) 2018-03-28 09:04:49 -07:00
8536126e23 removing tacho (#382) 2018-03-28 09:04:28 -07:00
f1ea113fc0 0.1.6 2018-03-28 08:50:34 -07:00
550528c695 bringing back show ports (#377)
* bringing back show ports

* added firmware links in docs

* updated color rendering

* better rendering of touch/ultra/ir

* better data per sensor
2018-03-28 08:50:14 -07:00
89e1819399 Applying home screen UI changes (#378) 2018-03-27 16:30:43 -07:00
e8fea031b2 0.1.5 2018-03-26 11:38:24 -07:00
0429c77d94 bump pxt-core to 3.5.11, 2018-03-26 11:38:20 -07:00
f41a646541 Small batch of 'activity' edits (#376) 2018-03-23 16:26:46 -07:00
988bec00b2 More updates for 'Try' and 'Use' topix (#375) 2018-03-22 14:16:14 -07:00
6e714caa2b Remove console log from colour field 2018-03-22 09:55:08 -07:00
336b7a5bf5 Incremental update to 'try' and 'use' topics (#374) 2018-03-21 12:36:49 -07:00
918dc802e9 Update 'make it faster' lesson (#373) 2018-03-20 16:11:32 -07:00
adbda6e35f Update 'make it communicate' lesson (#372) 2018-03-19 21:07:30 -07:00
77365ddd92 Snap to a specific version of less and semantic ui. (#371) 2018-03-19 13:42:15 -07:00
5ba1e85f84 Update 'Make it Move WO Wheels' lesson (#370) 2018-03-19 13:27:44 -07:00
f577c61998 Make corrections to coding activities (#369)
* Make corrections to coding activities

* Bit of format and typos
2018-03-19 12:26:29 -07:00
06f66571cf Upgrading to pxt 3.5.4 (#367)
* pxt/common updates

* added game lib

* removing gamelib
2018-03-16 14:32:11 -07:00
d714e4df42 Update lessons and change images (#368)
* Update lessons and change images

* Delete suptopic file
2018-03-16 14:26:14 -07:00
fc877b889c 0.1.4 2018-03-08 14:34:47 -08:00
49dc3b0a75 Fix resizing of screen canvas to ensure it fits within the area in the ev3 svg (#365) 2018-03-08 14:34:27 -08:00
994e57c395 Remove all external packages, will add later the ones we want (#364) 2018-03-08 14:20:52 -08:00
a6298078ba 0.1.3 2018-03-08 14:15:48 -08:00
acc55506cb Update index-ref.json 2018-03-08 14:14:33 -08:00
0c7d31770d Make a sound machine lesson (#363) 2018-03-08 07:12:52 -08:00
8c2ede17a0 'Make a security gadget' lesson (#362)
* Make a sound machine lesson

* Switch to security gadget
2018-03-08 07:12:18 -08:00
be55a342ff Bring back the pxt footer (#361) 2018-03-07 09:49:49 -08:00
d356c87c83 Remove social buttons in footer (#360) 2018-03-07 09:46:57 -08:00
2abf59010e Import 'object detection' activity (#359) 2018-03-02 18:02:26 -07:00
9360f938b7 Import 'line detection' activity (#358) 2018-03-02 17:35:40 -07:00
3006af3e63 Import 'autonomous parking' activity (#357) 2018-03-02 17:03:40 -07:00
d5b55585cd Remove redundant color word in the color blocks, refer to the color sensor with 'color sensor' (#356) 2018-03-02 09:01:18 -07:00
ab3c4c5267 Example overrides for 'music' api docs (#353)
* Example overrides for 'music' api docs

* Drop 'music' into card page
2018-02-27 17:15:26 -08:00
6d07d5bd23 Consolidate 'coding' activities into single pages (#354) 2018-02-27 17:15:12 -08:00
eb45a76928 Example overrides for 'control' api docs (#352)
* Add 'playSound' api docs

* Example overrides for 'control' api docs
2018-02-27 15:12:23 -08:00
fcba14aae1 Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-02-27 11:48:54 -08:00
44c68a7c0e fixing layout images 2018-02-27 11:48:50 -08:00
d4b3ebc2e4 Missing updatestats (#351)
* aligning screeninit with pxt32

* remove shim

* missing shim

* missing shim
2018-02-26 21:25:04 -08:00
fa5ba504c5 bump common packages 2018-02-26 16:21:18 -08:00
2d639b9a90 pointing master to 0.1.2 2018-02-26 16:14:04 -08:00
f8b8fbb1b4 0.1.2 2018-02-26 15:59:57 -08:00
594ead703c fixing mood block (#349) 2018-02-26 15:59:36 -08:00
5f05934dda 0.1.1 2018-02-26 15:17:14 -08:00
3e0ca1acb9 bump minor 2018-02-26 15:17:06 -08:00
c2d26a8418 Integrate screen APIs from common packages (#343)
* starting screen api intergration

* Further image integration

* Aligning with new screen apis

* Build fixes

* Adjust to common screen state

* Fix unpackPNG

* Add game library

* Optimize screen rendering

* bumping common packages

* updated shims

* moving images into ev3

* upgrading to common packages

* added try/use

* cap

* fixed tryp age
2018-02-26 15:16:17 -08:00
5bd9705966 0.0.109 2018-02-26 14:49:15 -08:00
1160d73b16 bump pxt-core to 3.4.9, bump pxt-common-packages to 0.20.3, 2018-02-26 14:49:00 -08:00
a2218d9ba5 Fix canvas (screen) user select options to disable selection in Safari, Mozilla, etc. (#348) 2018-02-26 13:58:51 -08:00
54576ae77a Fix authoring of the mood field editor. (#347) 2018-02-26 13:52:26 -08:00
f16549d7cd 0.0.108 2018-02-26 13:38:20 -08:00
a021c0b292 Use a color picker for the color field (color enum picker) (#346) 2018-02-26 13:37:58 -08:00
cda7013e96 fixing links 2018-02-26 13:27:03 -08:00
2f0fefbeaf updated images 2018-02-26 13:25:53 -08:00
b5303a660b 0.0.107 2018-02-26 11:22:44 -08:00
a60958f72a Update search icon and avatar SVG (#345) 2018-02-26 10:43:29 -08:00
33dcb6deee renaming infraredSensor to infrared (#344) 2018-02-26 10:39:15 -08:00
130a47d684 Sensor names are now part of the block text (#341)
* Sensor names are now part of the block text

* Use ports field editor
2018-02-26 11:33:50 -05:00
2d355bb2ca Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-02-23 20:38:53 -08:00
8ee63df325 Add in 'console' doc stuff (#342)
* Add 'playSound' api docs

* Add in 'console' doc stuff

* Add 'send to screen' in summary\
2018-02-23 14:13:08 -08:00
7d16cf10ac added make it smarter 2018-02-23 07:37:32 -08:00
60ec3f1c99 Add 'playSound' api docs (#340)
* Add 'playSound' api docs

* Linkup summary
2018-02-22 16:23:07 -08:00
6524b0a841 Add 'timer' api docs (#339) 2018-02-22 14:56:15 -08:00
d778232155 removing .mp4 file 2018-02-22 10:24:40 -08:00
c157b4d922 0.0.106 2018-02-22 10:18:13 -08:00
0837123828 bumping pxt 2018-02-22 10:15:58 -08:00
e51a32b69f use full motor names (#338) 2018-02-22 10:03:25 -08:00
029066000d updated style 2018-02-22 08:28:42 -08:00
7e35abeff3 lock on 0.0.104 2018-02-22 06:54:18 -08:00
0166785c1b 0.0.105 2018-02-22 06:36:41 -08:00
ea0f6a4734 updated pxt 2018-02-22 06:36:26 -08:00
271721561d turn sample into blocks 2018-02-21 22:39:35 -08:00
ed8f8bafa7 Add 'infrared beacon' api topics (#330)
* Add 'infrared beacon' api topics

* Include note about channel selection
2018-02-21 22:35:51 -08:00
8cfb70c97b Threshold api docs - 01 (#336)
* Local commit

* Throw on more topics

* Throw in threshold topics for infrared
2018-02-21 22:35:25 -08:00
84c8e31ff5 First burst of 'color' pages (#335)
* Add 'color sensor' api topics

* Last set of edits/adds
2018-02-21 14:03:55 -08:00
ceb9b7fabf 0.0.104 2018-02-21 06:45:29 -08:00
9e0670551f upgrading pxt 2018-02-21 06:45:14 -08:00
6613607503 Make it comm lesson (#331)
* integrating lego lesson

* fixed link

* adding various solutions

* updatring to 3.4.6

* using play sound effect until done

* revert pxtversion

* fixing link
2018-02-21 06:43:53 -08:00
3a67190914 Add some 'infrared' api docs (#326)
* Add some 'infrared' api docs

* Fix display messages

* Change discussion of distance to relative

* Include motor speed note
2018-02-20 10:38:41 -08:00
05e916e247 0.0.103 2018-02-19 07:35:38 -08:00
fad4ca98db renaming 'set speed' to 'run' (#327) 2018-02-19 07:35:08 -08:00
3b6cfed5b2 added distance measurer 2018-02-15 13:56:50 -08:00
472ea170d0 fixing default light 2018-02-15 13:49:04 -08:00
80f24948ec 0.0.102 2018-02-14 16:05:40 -08:00
daa88b299d replacing loops.pause -> pause, loops.forever -> forever 2018-02-14 16:05:31 -08:00
0384eb4d9d upgrading common packages 2018-02-14 15:59:08 -08:00
f33f88e87c fixing struture 2018-02-14 11:20:56 -08:00
239827c259 0.0.101 2018-02-14 11:06:56 -08:00
cd0097749a updated readme 2018-02-14 11:00:12 -08:00
94db31beb7 bring back the shims 2018-02-14 10:56:50 -08:00
408631d426 upgrading common packages 2018-02-14 10:32:09 -08:00
2407e7e179 0.0.100 2018-02-14 10:16:57 -08:00
f63b447fee upgraded to v3.4.3 2018-02-14 10:16:27 -08:00
bbd1a9d215 Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-02-14 10:15:28 -08:00
cfc4688fbe adding targetconfig to package 2018-02-14 09:49:47 -08:00
24d48c0171 update firmware url 2018-02-14 09:36:20 -08:00
523c507c35 Projectupdate1 (#325)
* integrating test lesson from lego

* adding side card annotations
2018-02-14 08:56:12 -08:00
d6cbbcc3d9 support for importing urls 2018-02-13 21:41:49 -08:00
2b5cedb404 0.0.99 2018-02-13 11:26:41 -08:00
224e9c54f0 color dropdown for color sensor (#324) 2018-02-13 10:44:46 -08:00
f3f33828f3 Fixed the dropdown for colors (#323) 2018-02-12 21:23:16 -08:00
2905814898 0.0.98 2018-02-12 12:26:08 -08:00
96f1086c8f Applying UI updates from Lego (#322) 2018-02-12 12:23:25 -08:00
7bd2192a0a Fill in some ultrasonic sensor topics (#321)
* Fill in some ultrasonic sensor topics

* Busted link

* Adjust those sea also links

* Busted snippets
2018-02-11 09:01:46 -08:00
6f539de2d2 Touch sensor doc fill-in (#320) 2018-02-09 18:17:12 -08:00
1d83d6c40e 0.0.97 2018-02-09 10:26:28 -08:00
53bff7b133 updated package lock 2018-02-09 10:26:20 -08:00
2f6ad3110a motor blocks with optional args (#290)
* motor blocks with optional args

* updated signatures

* added toggle mode

* adding annotations
2018-02-09 10:25:39 -08:00
22ce840181 Widget fixes (#316)
* Use bBox in motor slider

* Use setRate instead of setAngle in gyro widget
2018-02-08 16:55:23 -08:00
d8589ea98c Discussion note for gyro precsion (#317)
* Discussion note for gyro precsion

* Wrong sig
2018-02-08 15:06:08 -08:00
adb577547d 0.0.96 2018-02-08 12:53:17 -08:00
ab6290c76d Add blocky grid (#313) 2018-02-08 11:49:26 -08:00
99d4d87894 0.0.95 2018-02-08 09:36:08 -08:00
b73696e918 Gyro sensor topics (#311) 2018-02-08 09:35:47 -08:00
f53dbf4d83 Include Open Sans font and some UI tweaks reducing white space in the editor. (#312) 2018-02-08 09:35:27 -08:00
c9f6d873b1 Edit LabView user help doc (#310) 2018-02-07 13:55:49 -08:00
c274259472 0.0.94 2018-02-07 09:54:24 -08:00
74ca722aac updated IR arts 2018-02-07 09:53:58 -08:00
931ca40f49 updated IR art 2018-02-07 08:13:46 -08:00
458ac847b7 updated assets for LEGO 2018-02-07 07:13:22 -08:00
636 changed files with 23514 additions and 9965 deletions

35
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
Add screenshots to help explain your problem. You can copy paste the screenshot in the github report. The .gif screen recording is very useful as well.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View File

@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

2
.gitignore vendored
View File

@ -17,8 +17,6 @@ clients/**/bin/**
clients/**/obj/**
clients/electron/projects
libs/**/_locales/**
libs/**/shims.d.ts
libs/**/enums.d.ts
videos/**

View File

@ -1,8 +1,8 @@
# LEGO Mindstorms EV3 target for PXT
# LEGO® MINDSTORMS® Education EV3 for Microsoft MakeCode
[![Build Status](https://ci2.dot.net/buildStatus/icon?job=Private/pxt_project_rainbow/master/pxt-ev3_Push)](https://ci2.dot.net/job/Private/job/pxt_project_rainbow/job/master/job/pxt-ev3_Push/)
This repo contains the editor target hosted at https://d541eec2-1e96-4b7b-a223-da9d01d0337a.pxt.io/
This repo contains the editor target hosted at https://makecode.legoeducation.com
LEGO Auth: https://src.education.lego.com/groups/ev3-makecode (use Google Authenticator)
LEGO Chat: https://chat.internal.education.lego.com/make-code/channels/town-square
@ -11,7 +11,7 @@ LEGO Chat: https://chat.internal.education.lego.com/make-code/channels/town-squa
These instructions assume familiarity with dev tools and languages.
* install Node.js 6+
* install Node.js 8.9.4+
* install Docker; make sure `docker` command is in your `PATH`
* (optional) install [Visual Studio Code](https://code.visualstudio.com/)
@ -24,7 +24,6 @@ In a common folder,
```
npm install
typings install
```
* go to ``pxt-common-packages`` and run
@ -58,12 +57,6 @@ cd libs/core
pxt deploy
```
### Hosted editor
Currently hosted at:
https://d541eec2-1e96-4b7b-a223-da9d01d0337a.pxt.io/
### Jenkins build
https://ci2.dot.net/job/Private/job/pxt_project_rainbow/job/master/

View File

@ -1,6 +0,0 @@
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
import * as path from "path";
export let pxtCore = require("pxt-core");
// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir
export let pxtCoreDir = path.resolve(require.resolve("pxt-core"), "..", "..");

16
docfiles/footer.html Normal file
View File

@ -0,0 +1,16 @@
<footer class="ui inverted accent vertical footer segment hideprint" aria-hidden="false">
<div class="ui center aligned container">
<div class="ui container horizontal inverted small divided link list">
<!-- <a class="item" href="https://makecode.com/contact" target="_blank" rel="noopener">Contact Us</a> -->
<a class="item" href="https://makecode.com/privacy" target="_blank" rel="noopener">Privacy &amp; Cookies</a>
<a class="item" href="https://makecode.com/termsofuse" target="_blank" rel="noopener"> Terms Of Use</a>
<a class="item" href="https://makecode.com/trademarks" target="_blank" rel="noopener">Trademarks</a>
<div class="item">© 2018 Microsoft</div>
<!-- we need to force the browser to load this font -->
<div style='font-family: Icons; color: #010101;' aria-hidden="true">.</div>
</div>
<div class="ui container horizontal inverted small divided link list">
<a class="ui centered item" href="https://makecode.com/" title="Microsoft MakeCode" target="_blank" rel="noopener">Powered by Microsoft MakeCode</a>
</div>
</div>
</footer>

View File

@ -1,42 +1,44 @@
# @extends
## Support #support
* [Troubleshoot](/troubleshoot)
* [EV3 Manager](https://ev3manager.education.lego.com/)
* [LEGO Support](https://www.lego.com/service/)
## Projects #projects
* [Maker](/maker)
* [Sound Machine](/maker/sound-machine)
* [Sound of Color](/maker/sound-of-color)
* [Security Gadget](/maker/security-gadget)
* [Intruder detector](/maker/intruder-detector)
* [Puppet](/maker/puppet)
* [Getting Started](/getting-started)
* [Try](/getting-started/try)
* [Use](/getting-started/use)
* [Tutorials](/tutorials)
* [Wake Up!](/tutorials/wake-up)
* [Make An Animation](/tutorials/make-an-animation)
* [What Animal Am I?](/tutorials/what-animal-am-i)
* [Music Brick](/tutorials/music-brick)
* [Run Motors](/tutorials/run-motors)
* [Touch to Run](/tutorials/touch-to-run)
* [Touch Sensor Values](/tutorials/touch-sensor-values)
* [What Color?](/tutorials/what-color)
* [Line Following](/tutorials/line-following)
* [Red Light, Green Light](/tutorials/redlight-greenlight)
* [Object Near?](/tutorials/object-near)
* [Security Alert](/tutorials/security-alert)
* [Coding](/coding)
* [Three Point Turn 1](/coding/three-point-turn-1)
* [Three Point Turn 2](/coding/three-point-turn-2)
* [Three Point Turn 3](/coding/three-point-turn-3)
* [Reversing the robot 1](/coding/reversing-the-robot-1)
* [Reversing the robot 2](/coding/reversing-the-robot-2)
* [Reversing the robot 3](/coding/reversing-the-robot-3)
* [Light the way 1](/coding/light-the-way-1)
* [Light the way 2](/coding/light-the-way-2)
* [Light the way 3](/coding/light-the-way-3)
* [Traffic Lights 1](/coding/traffic-lights-1)
* [Traffic Lights 2](/coding/traffic-lights-2)
* [Traffic Lights 3](/coding/traffic-lights-3)
* [Reverse Beeper 1](/coding/reverse-beeper-1)
* [Reverse Beeper 2](/coding/reverse-beeper-2)
* [Reverse Beeper 3](/coding/reverse-beeper-3)
* [Ignition 1](/coding/ignition-1)
* [Ignition 2](/coding/ignition-2)
* [Ignition 3](/coding/ignition-3)
* [Cruise Control 1](/coding/cruise-control-1)
* [Cruise Control 2](/coding/cruise-control-2)
* [Cruise Control 3](/coding/cruise-control-3)
* [Roaming 1](/coding/roaming-1)
* [Roaming 2](/coding/roaming-2)
* [Autonomous Parking](/coding/autonomous-parking)
* [Object Detection](/coding/object-detection)
* [Line Detection](/coding/line-detection)
* [Design Engineering](/design-engineering)
* [Make It Move Without Wheels](/design-engineering/make-it-move)
* [Make It Smarter and Faster](/design-engineering/make-it-smarter)
* [Make a System that Communicates](/design-engineering/make-it-communicate)
* [Lessons](/lessons)
* [Make it move](/lessons/make-it-move)
* [Line detection](/lessons/line-detection)
* [Maker](/maker)
* [Make a Sound Machine](/maker/sound-machine)
* [Make a Security Gadget](/maker/security-gadget)
## Reference #reference
@ -48,6 +50,7 @@
* [show mood](/reference/brick/show-mood)
* [show image](/reference/brick/show-image)
* [clear screen](/reference/brick/clear-screen)
* [show ports](/reference/brick/show-ports)
* [on event](/reference/brick/button/on-event)
* [is pressed](/reference/brick/button/is-pressed)
* [was pressed](/reference/brick/button/was-pressed)
@ -55,7 +58,7 @@
* [set light](/reference/brick/set-status-light)
* [battery level](/reference/brick/battery-level)
* [Motors](/reference/motors)
* [set speed](/reference/motors/motor/set-speed)
* [run](/reference/motors/motor/run)
* [stop](/reference/motors/motor/stop)
* [reset](/reference/motors/motor/reset)
* [set brake](/reference/motors/motor/set-brake)
@ -63,8 +66,60 @@
* [set regulated](/reference/motors/motor/set-regulated)
* [tank](/reference/motors/synced/tank)
* [steer](/reference/motors/synced/steer)
* [tacho](/reference/motors/motor/tacho)
* [angle](/reference/motors/motor/angle)
* [speed](/reference/motors/motor/speed)
* [clear counts](/reference/motors/motor/clear-counts)
* [stop all motors](/reference/motors/stop-all-motors)
* [stop all motors](/reference/motors/stop-all)
* [Sensors](/reference/sensors)
* [Touch](/reference/sensors/touch-sensor)
* [on event](/reference/sensors/touch-sensor/on-event)
* [pause until](/reference/sensors/touch-sensor/pause-until)
* [is pressed](/reference/sensors/touch-sensor/is-pressed)
* [was pressed](/reference/sensors/touch-sensor/was-pressed)
* [Gyro](/reference/sensors/gyro)
* [angle](/reference/sensors/gyro/angle)
* [rate](/reference/sensors/gyro/rate)
* [reset](/reference/sensors/gyro/reset)
* [Ultrasonic](/reference/sensors/ultrasonic)
* [on event](/reference/sensors/ultrasonic/on-event)
* [distance](reference/sensors/ultrasonic/distance)
* [pause until](reference/sensors/ultrasonic/pause-until)
* [Infrared](/reference/sensors/infrared)
* [on event](/reference/sensors/infrared/on-event)
* [distance](reference/sensors/infrared/proximity)
* [pause until](reference/sensors/infrared/pause-until)
* [Infrared beacon](/reference/sensors/beacon)
* [on event](/reference/sensors/beacon/on-event)
* [pause until](/reference/sensors/beacon/pause-until)
* [is pressed](/reference/sensors/beacon/is-pressed)
* [was pressed](/reference/sensors/beacon/was-pressed)
* [set remote channel](/reference/sensors/beacon/set-remote-channel)
* [Color](/reference/sensors/color-sensor)
* [on color detected](/reference/sensors/color-sensor/on-color-detected)
* [pause until color detected](/reference/sensors/color-sensor/pause-until-color-detected)
* [on light detected](/reference/sensors/color-sensor/on-light-detected)
* [pause until light condition detected](/reference/sensors/color-sensor/pause-until-light-detected)
* [color](/reference/sensors/color-sensor/color)
* [light](/reference/sensors/color-sensor/ambient-light)
* [Music](/reference/music)
* [play sound effect](/reference/music/play-sound-effect)
* [play sound effect until done](/reference/music/play-sound-effect-until-done)
* [play tone](/reference/music/play-tone)
* [ring tone](/reference/music/ring-tone)
* [stop all sounds](/reference/music/stop-all-sounds)
* [rest](/reference/music/rest)
* [change tempo by](/reference/music/change-tempo-by)
* [set tempo](/reference/music/set-tempo)
* [note frequency](/reference/music/note-frequency)
* [beat](/reference/music/beat)
* [set volume](/reference/music/set-volume)
* [Control](/reference/control)
* [Timer](/reference/control/timer)
* [seconds](/reference/control/timer/seconds)
* [millis](/reference/control/timer/millis)
* [reset](/reference/control/timer/reset)
* [pause until](/reference/control/timer/pause-until)
* [Console](/reference/console)
* [log](/reference/console/log)
* [log value](/reference/console/log-value)
* [send to screen](/reference/console/send-to-screen)

View File

@ -8,32 +8,40 @@ You can program the @boardname@ using [Blocks](/blocks) or [JavaScript](/javascr
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.setSpeed(50)
motors.largeA.run(50)
})
```
```typescript
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.setSpeed(50)
motors.largeA.run(50)
})
```
The editor work in [most modern browsers](/browsers), work [offline](/offline) once loaded and do not require any installation.
The editor works in [most modern browsers](/browsers). It works [offline](/offline) once loaded and doesn't require any installation. Take a look at some of the [features](/about/editor-features) of the editor.
## Compile and Flash: Your Program!
When you have your code ready, you connect your @boardname@ to a computer via a USB cable
so it appears as a mounted drive (named **EV3**).
When you have your code ready, you connect your EV3 Brick to a computer with a USB cable so it appears as an attached drive (named **@drivename@**).
Compilation to machine code from [Blocks](/blocks) or [JavaScript](/javascript) happens in the browser. You save the binary
program to a **.uf2** file, which you then copy to the **EV3** drive, which flashes the device with the new program.
program to a **.uf2** file, which you then copy to the **@drivename@** drive. The process of copying will flash the device with the new program.
### ~ hint
Not seeing the **@drivename@** drive? Make sure to upgrade your firmware at https://ev3manager.education.lego.com/. Try these [troubleshooting](/troubleshoot) tips if you still have trouble getting the drive to appear.
### ~
## Simulator: Test Your Code
You can run your code using the micro:bit simulator, all within the confines of a web browser.
The simulator has support for the LED screen, buttons, as well as compass, accelerometer, and digital I/O pins.
You can run your code using the @boardname@ simulator, all inside the same browser window.
The simulator has support for the EV3 Brick screen, buttons, sensors, and motors.
```sim
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.setSpeed(50)
motors.largeA.run(50)
motors.mediumD.run(50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected)
})
```
```

View File

@ -0,0 +1,72 @@
# @extends
#### #blocks-images
| |
|-|
| ![Blocks Toolbox with Loops shelf open](/static/about/blocks-toolbox.png) |
| Blocks Toolbox |
#### #home-images
| |
|-|
| ![Home button](/static/about/home-button.png) |
| Home Button |
#### #share-images
| |
|-|
| ![Share button](/static/about/share-button.png) |
| Share Button |
#### #blocksjs-images
| |
|-|
| ![Switch from Blocks to JavaScript](/static/about/blocks-to-js.gif) |
| Switch from Blocks to JavaScript |
#### #help-images
| |
|-|
| ![Help button](/static/about/help-button.png) |
| Help Button |
#### #moresettings-images
| |
|-|
| ![More settings button](/static/about/more-settings.png) |
| More Button |
#### #undoredo-images
| | | |
|-|-|-|
| ![Undo button](/static/about/undo-button.png) | | ![Redo button](/static/about/redo-button.png) |
| Undo Button | | Redo Button |
#### #zoom-images
| | | |
|-|-|-|
| ![Zoom in button](/static/about/zoom-in.png) | | ![Zoom out button](/static/about/zoom-out.png) |
| Zoom In | | Zoom Out |
#### #saveproject-images
| |
|-|
| ![Save project field](/static/about/save-project.png) |
| Save Project |
#### #download-images
| |
|-|
| ![Download button](/static/about/download-button.png) |
| Download Button |

View File

@ -3,6 +3,6 @@
### #specific
```cards
loops.forever(() => {});
loops.pause(0)
forever(() => {});
pause(0)
```

View File

@ -1,171 +1,27 @@
# Coding Activites
12 computer science activities, with cross-curricular opportunities in design and technology, science, and math.
* [Download Curriculum Materials](https://education.lego.com/en-us/downloads/mindstorms-ev3)
## Three Point Turn
## Projects
```codecard
[
{
"name": "Three Point Turn 1",
"description": "Activity 1",
"url":"/coding/three-point-turn-1",
"cardType": "example"
"name": "Autonomous Parking",
"description": "Design cars that can park themselves safely without driver intervention.",
"url":"/coding/autonomous-parking",
"imageUrl": "/static/lessons/autonomous-parking.png",
"cardType": "side"
}, {
"name": "Three Point Turn 2",
"description": "Activity 2",
"url":"/coding/three-point-turn-2",
"cardType": "example"
"name": "Object Detection",
"description": "Design ways to avoid accidents between vehicles and objects in the road.",
"url":"/coding/object-detection",
"imageUrl": "/static/lessons/object-detection.jpg",
"cardType": "side"
}, {
"name": "Three Point Turn 3",
"description": "Activity 3",
"url":"/coding/three-point-turn-3",
"cardType": "example"
}]
```
## Reversing the robot
```codecard
[{
"name": "Reversing the robot 1",
"description": "Activity 1",
"url":"/coding/reversing-the-robot-1",
"cardType": "example"
}, {
"name": "Reversing the robot 2",
"description": "Activity 2",
"url":"/coding/reversing-the-robot-2",
"cardType": "example"
}, {
"name": "Reversing the robot 3",
"description": "Activity 3",
"url":"/coding/reversing-the-robot-3",
"cardType": "example"
}]
```
## Light the way
```codecard
[{
"name": "Light the way 1",
"description": "Activity 1",
"url":"/coding/light-the-way-1",
"cardType": "example"
}, {
"name": "Light the way 2",
"description": "Activity 2",
"url":"/coding/light-the-way-2",
"cardType": "example"
}, {
"name": "Light the way 3",
"description": "Activity 3",
"url":"/coding/light-the-way-3",
"cardType": "example"
}
]
```
## Traffic Lights
```codecard
[{
"name": "Traffic Lights 1",
"description": "Activity 1",
"url":"/coding/traffic-lights-1",
"cardType": "example"
}, {
"name": "Traffic Lights 2",
"description": "Activity 2",
"url":"/coding/traffic-lights-2",
"cardType": "example"
}, {
"name": "Traffic Lights 3",
"description": "Activity 3",
"url":"/coding/traffic-lights-3",
"cardType": "example"
}
]
```
## Reverse Bepper
```codecard
[{
"name": "Reverse Beeper 1",
"description": "Activity 1",
"url":"/coding/reverse-beeper-1",
"cardType": "example"
}, {
"name": "Reverse Beeper 2",
"description": "Activity 2",
"url":"/coding/reverse-beeper-2",
"cardType": "example"
}, {
"name": "Reverse Beeper 3",
"description": "Activity 3",
"url":"/coding/reverse-beeper-3",
"cardType": "example"
}]
```
## Ignition
```codecard
[{
"name": "Ignition 1",
"description": "Activity 1",
"url":"/coding/ingition-1",
"cardType": "example"
}, {
"name": "Ignition 2",
"description": "Activity 2",
"url":"/coding/ignition-2",
"cardType": "example"
}, {
"name": "Ignition 3",
"description": "Activity 3",
"url":"/coding/ignition-3",
"cardType": "example"
}]
```
## Cruise Control
```codecard
[{
"name": "Cruise Control 1",
"description": "Activity 1",
"url":"/coding/cruise-control-1",
"cardType": "example"
}, {
"name": "Cruise Control 2",
"description": "Activity 2",
"url":"/coding/cruise-control-2",
"cardType": "example"
}, {
"name": "Cruise Control 3",
"description": "Activity 3",
"url":"/coding/cruise-control-3",
"cardType": "example"
}]
```
## Roaming
```codecard
[{
"name": "Roaming 1",
"description": "Activity 1",
"url":"/coding/roaming-1",
"cardType": "example"
}, {
"name": "Roaming 2",
"description": "Activity 2",
"url":"/coding/roaming-2",
"cardType": "example"
"name": "Line Detection",
"description": "Design ways to improve driving safety by helping to prevent drivers from falling asleep and causing an accident.",
"url":"/coding/line-detection",
"imageUrl": "/static/lessons/line-detection.jpg",
"cardType": "side"
}]
```

View File

@ -0,0 +1,171 @@
# Autonomous Parking
Design cars that can park themselves safely without driver intervention.
![Autonomous parking graphic](/static/coding/autonomous-parking/auto-parking-connect.jpg)
## Connect
**Think about:**
* How do autonomous cars work?
* What would it take to ensure that autonomous cars are safe?
* What types of movements do autonomous cars need to perform?
## Construct
### Build
Build a @boardname@ vehicle that can park itself safely without driver intervention. Start by constructing this model:
[![EV3- Robot Driving Base](/static/coding/autonomous-parking/ev3-robot-driving-base.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf)
### Check
Before you program, check:
* Are all the wires correctly connected from the motors to ports B and C?
* Are the wheels correctly installed?
* Are the wheels rotating freely?
### Program
Write a program that will make the robot turn three times in various ways.
**Think about:**
* How will you make the robot turn in different ways?
* How can the robot make a three point turn?
### ~hint
Consider using these blocks in your solution:
```block
motors.largeBC.tank(50, 50)
pause(500)
```
### ~
### Sample Solution - Three Point Turn
1. When the brick button is pressed, turn the driving base right and stop after 1.5 seconds.
2. Turn the driving base left and stop after 1 second.
3. Move the driving base forward for 3 seconds.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
motors.largeBC.tank(-30, -75)
loops.pause(1000)
motors.largeBC.tank(50, 50)
loops.pause(3000)
})
```
### Download and test
Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Contemplate
Choose one of the following autonomous driving scenarios and create a program for it:
* Parallel parking
* Angle parking
* Perpendicular parking
### ~hint
Document pseudocode for your program before choosing programming blocks.
### ~
### Sample Solution - Parallel Parking
1. When the brick button is pressed, drive forward in a straight line for 3 rotations.
2. Wait for 1 second.
3. Reverse motor rotation while turning for 1.5 rotations.
4. Reverse motor rotation while turning the other way for 1.5 rotations.
5. Drive backward in a straight line for 0.5 rotations.
6. Drive forward in a straight line for 0.5 rotations.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 50, 3, MoveUnit.Rotations)
pause(1000)
motors.largeBC.steer(-50, -50, 1.5, MoveUnit.Rotations)
motors.largeBC.steer(50, -50, 1.5, MoveUnit.Rotations)
motors.largeBC.steer(0, -50, 0.5, MoveUnit.Rotations)
motors.largeBC.steer(0, 50, 0.5, MoveUnit.Rotations)
})
```
### Download and test
Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
### Differentiation
Create a program that simulates displaying appropriate warning lights while parking.
### ~hint
Consider using this block in your solution:
```block
brick.setStatusLight(StatusLight.OrangeFlash)
```
### ~
### Sample Solution - Simulating Reverse Gear and Reverse Warning Lights
1. When the brick button is pressed, drive forward in a straight line for 3 rotations.
2. Wait for 1 second.
3. Set brick status light to orange flash.
4. Reverse motor rotation while turning for 1.5 rotations.
5. Reverse motor rotation while turning the other way for 1.5 rotations.
6. Drive backward in a straight line for 0.5 rotations.
7. Set brick status light to off.
8. Drive forward in a straight line for 0.5 rotations.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 50, 3, MoveUnit.Rotations)
pause(1000)
brick.setStatusLight(StatusLight.OrangeFlash)
motors.largeBC.steer(-50, -50, 1.5, MoveUnit.Rotations)
motors.largeBC.steer(50, -50, 1.5, MoveUnit.Rotations)
motors.largeBC.steer(0, -50, 0.5, MoveUnit.Rotations)
brick.setStatusLight(StatusLight.Off)
motors.largeBC.steer(0, 50, 0.5, MoveUnit.Rotations)
})
```
### Download and test
Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
### Share
**Think about:**
* What challenged you?
* Were there any surprises?
* How can you improve your program?
* Can your program be more streamlined? Have you used too many blocks?
* Is there a more efficient way to build your program?
* How can your program be used in real-world scenarios?
## Continue
* Click on the JavaScript tab and experiment with changing the values in the code.
* Add a custom image or sounds from the Brick or Music menus.
* Create a video of your project, especially your final presentation and your robots performance. Explain some important features of your software program.
* Include an image of your program with comments.
* Add a team photograph!
Congratulations! What will you design next?

View File

@ -1,10 +0,0 @@
# Cruise Control Activity 1
```blocks
let speed = 0;
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
if (speed < 100)
speed = speed + 10;
motors.largeBC.setSpeed(speed);
})
```

View File

@ -1,15 +0,0 @@
# Cruise Control Activity 2
```blocks
let speed = 0;
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
if (speed < 100)
speed = speed + 10;
motors.largeBC.setSpeed(speed);
})
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
if (speed > -100)
speed = speed - 10;
motors.largeBC.setSpeed(speed);
})
```

View File

@ -1,28 +0,0 @@
# Cruise Control Activity 3
```blocks
let speed = 0
function decelerate() {
if (speed > -100) {
speed = speed - 10
}
}
function accelerate() {
if (speed < 100) {
speed = speed + 10
}
}
function update() {
brick.clearScreen()
brick.showString("speed: " + speed, 1)
motors.largeBC.setSpeed(speed)
}
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
accelerate()
update()
})
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
decelerate()
update()
})
```

View File

@ -0,0 +1,65 @@
# Cruise Control
Learn how to set and adjust motor speeds.
## Activity 1
Increase motor speed when touch sensor `1` is pressed.
```blocks
let speed = 0;
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
if (speed < 100)
speed = speed + 10;
motors.largeBC.run(speed);
})
```
## Activity 2
Add a "reduce" motor speed action when touch sensor `2` is pressed.
```blocks
let speed = 0;
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
if (speed < 100)
speed = speed + 10;
motors.largeBC.run(speed);
})
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
if (speed > -100)
speed = speed - 10;
motors.largeBC.run(speed);
})
```
## Activity 3
Refactor your code by moving the speed increase and speed decrease code into ``||functions:accelerate||`` and ``||functions:decelerate||`` functions. Run the motors at the new speed in an ``||functions:update||`` function.
```blocks
let speed = 0
function decelerate() {
if (speed > -100) {
speed = speed - 10
}
}
function accelerate() {
if (speed < 100) {
speed = speed + 10
}
}
function update() {
brick.clearScreen()
brick.showString("speed: " + speed, 1)
motors.largeBC.run(speed)
}
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
accelerate()
update()
})
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
decelerate()
update()
})
```

View File

@ -1,11 +0,0 @@
# Ignition Activity 1
```blocks
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.eyesDizzy)
})
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectDetected, function () {
brick.showImage(images.eyesTiredMiddle)
})
brick.showImage(images.eyesSleeping)
```

View File

@ -1,12 +0,0 @@
# Ignition Activity 2
```blocks
while (true) {
if (sensors.touch1.wasPressed() &&
sensors.ultrasonic4.distance() < 10) {
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
}
loops.pause(1);
}
```

View File

@ -1,13 +0,0 @@
# Ignition Activity 3
```blocks
while (true) {
if (sensors.ultrasonic4.distance() < 10 &&
sensors.touch1.wasPressed() &&
brick.buttonEnter.wasPressed()) {
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
}
loops.pause(1);
}
```

48
docs/coding/ignition.md Normal file
View File

@ -0,0 +1,48 @@
# Ignition
Explore sensor events and sensor status.
## Activity 1
Wait for a touch sensor press or ultrasonic object detection. Show an expression on the screen when they happen.
```blocks
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.eyesDizzy)
})
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectDetected, function () {
brick.showImage(images.eyesTiredMiddle)
})
brick.showImage(images.eyesSleeping)
```
## Activity 2
Play some motor sounds if touch sensor `1` is pressed at the same moment when and object comes close.
```blocks
while (true) {
if (sensors.touch1.isPressed() &&
sensors.ultrasonic4.distance() < 10) {
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
}
pause(1);
}
```
## Activity 3
Play some motor sounds if touch sensor `1` is pressed when both the `enter` button is pressed on the brick and an object comes close.
```blocks
while (true) {
if (sensors.ultrasonic4.distance() < 10 &&
sensors.touch1.isPressed() &&
brick.buttonEnter.isPressed()) {
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
}
pause(1);
}
```

View File

@ -1,9 +1,9 @@
# Light the way Activity 1
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Dark, function () {
brick.showImage(images.objectsLightOn)
loops.pause(5000)
pause(5000)
brick.clearScreen()
})
```

View File

@ -1,10 +1,10 @@
# Light the way Activity 2
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Bright, function () {
sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Bright, function () {
brick.clearScreen()
})
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Dark, function () {
brick.showImage(images.objectsLightOn)
})
```

View File

@ -1,10 +1,10 @@
# Light the way Activity 3
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Bright, function () {
sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Bright, function () {
brick.clearScreen()
})
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
sensors.color3.onLightDetected(LightIntensityMode.Ambient, Light.Dark, function () {
brick.showImage(images.objectsLightOn)
})
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {

View File

@ -0,0 +1,239 @@
# Line Detection
Design ways to improve driving safety by helping to prevent drivers from falling asleep and causing an accident.
![Car following the line on the road](/static/coding/line-detection/car-road-line.jpg)
## Connect
Think about:
* How can autonomous cars react to different traffic light signals?
* What can happen if a driver falls asleep while driving?
* How can we detect when a driver is falling asleep?
## Construct
### Build
Build a @boardname@ vehicle that can help prevent drivers from falling asleep and causing an accident. Start by constructing this model:
[![EV3 robot with color sensor](/static/coding/line-detection/ev3-robot-color-sensor-down.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-color-sensor-down-driving-base-d30ed30610c3d6647d56e17bc64cf6e2.pdf)
Build red and green “lights” for your robot to detect. You can use LEGO bricks, colored tape, or marker on white paper. Building instructions:
[![IMAGE: Color Squares](/static/coding/line-detection/ev3-color-squares.jpg)](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/color%20squares-0a88dfd98bb2e64b5b8151fc422bae36.pdf)
### Check
Before you program, check:
* Are all the wires correctly connected from the motors to ports B and C?
* Are the wheels correctly installed?
* Are the wheels rotating freely?
* Are the wires connected from the Color Sensor to port 3?
![EV3 Driving Base](/static/coding/line-detection/ev3-robot-driving-base.jpg)
### Program
Autonomous cars need to recognize and respond to traffic lights automatically. Create a program that will make your robot stop at red lights. Make sure your robot is only responding to the color red. Once you have succeeded, program your robot to drive forward again when the light changes from red to green.
Before you program, think about:
* How will you program the robot to detect a color?
* How will you program the robot to stop at a color?
* Which programming blocks will you use?
### ~ hint
Consider using these blocks in your solution:
```block
loops.forever(function () {
})
motors.largeBC.steer(0, 50)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
```
### ~
### Sample Solution - Red light detection
1. Loop forever.
2. Start motors ``B`` and ``C`` (drive forward).
3. Wait for the color sensor to detect the color red.
4. Stop all motors.
```blocks
loops.forever(function () {
motors.largeBC.steer(0, 50)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
})
```
### Download and test
Click **Download** and follow the instructions to get your code onto your EV3 Brick.
Congratulations! Your robot can stop at a red light.
Now add to your program and have your robot to drive forward again when the light changes from red to green.
### Sample Solution - Red and green light detection in a loop
1. Start motors ``B`` and ``C`` (drive forward).
2. Wait for the color sensor to detect the color red.
3. Stop all motors.
4. Wait for the color sensor to detect the color green.
5. Loop forever.
```blocks
loops.forever(function () {
motors.largeBC.steer(0, 50)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
})
```
### Download and test
Click **Download** and follow the instructions to get your code onto your EV3 Brick.
## Contemplate
To simulate what could happen if a driver falls asleep while driving, your robot could sound an alarm signal when it crosses the line. This feature is often available in new cars.
Program your robot to perform this function.
Draw a dark line with tape or marker for your robot to cross.
### ~hint
Consider using these blocks in your solution:
```block
motors.largeBC.steer(0, 50)
music.playSoundEffect(sounds.systemGeneralAlert)
```
### ~
### Sample Solution - Line detection in a loop
1. Start motors ``B`` and ``C`` (drive forward with a curve toward the line).
2. Wait for the color sensor to detect the color black.
3. Play sound effect ``system general alert``.
4. Start motors ``B`` and ``C`` (drive forward with a curve away from the line).
5. Wait for the color sensor to detect the color white.
6. Loop forever.
```blocks
loops.forever(function () {
motors.largeBC.steer(-30, 20)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
music.playSoundEffect(sounds.systemGeneralAlert)
motors.largeBC.steer(30, 20)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
})
```
#### Download and test
Click **Download** and follow the instructions to get your code onto your EV3 Brick.
#### Differentiation
Program your robot to drive on “autopilot” along a given route. You will need to create a program that recognizes and responds to a dark line (or white line). You will create a line-following program and your robot will need to travel along the line without losing contact with it.
You will need to constantly debug your program in order to make your robot travel as smoothly as possible along the line.
### ~hint
Consider using these blocks in your solution:
```block
while (true) {
}
motors.largeBC.steer(0, 50)
```
> **- OR -**
```block
if (true) {
} else {
}
```
### ~
### Sample Solutions - Line Following in Loop
#### Method 1
1. While the Color Sensor detects the color black, start motors ``B`` and ``C`` (drive forward with a curve toward the line).
2. While the Color Sensor detects the color white, start motors ``B`` and ``C`` (drive forward with a curve away from the line).
3. Loop forever.
```blocks
forever(function () {
while (true) {
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
motors.largeBC.steer(-30, 50)
}
while (true) {
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
motors.largeBC.steer(30, 50)
}
})
```
#### Method 2
1. If the Color Sensor detects the color black, start motors ``B`` and ``C`` (drive forward with a curve toward the line).
Else the Color Sensor detects the color white, start motors ``B`` and ``C`` (drive forward with a curve away from the line).
2. Loop forever.
```blocks
forever(function () {
if (true) {
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
motors.largeBC.steer(-30, 50)
} else {
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
motors.largeBC.steer(30, 50)
}
})
```
### Download and test
Click **Download** and follow the instructions to get your code onto your EV3 Brick.
### Share
Think about:
* What challenged you?
* Were there any surprises?
* How can you improve your program?
* Can your program be more streamlined? Have you used too many blocks?
* Is there a more efficient way to build your program?
* How can your program be used in real-world scenarios?
Personalize:
* Click on the **JavaScript** tab and experiment with changing the values in the code.
* Add a custom image or sounds from the ``||brick:Brick||`` or ``||music:Music||`` menus.
* Create a video of your project, especially your final presentation and your robots performance. Explain some important features of your software program.
* Include an image of your program with comments.
* Add a team photograph!
Congratulations! What will you design next?

View File

@ -0,0 +1,137 @@
# Object Detection
Design ways to avoid accidents between vehicles and objects in the road.
![Deer in the road](/static/coding/object-detection/road-deer.jpg)
## Connect
Think about:
* In what driving situations can a car hit an obstacle?
* What do you need to be aware of to avoid collisions with obstacles?
* What causes traffic jams in high density areas?
## Construct
### Build
Build a @boardname@ vehicle that can avoid accidents between vehicles and objects in the road. Start by constructing this model:
[![EV3 Robot Driving Base](/static/coding/object-detection/ev3-robot-driving-base.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-ultrasonic-sensor-driving-base-61ffdfa461aee2470b8ddbeab16e2070.pdf)
Build an obstacle for your robot to detect. You can build the **cuboid model** out of LEGO bricks or an obstacle of your choice.
[![Cubiod block](/static/coding/object-detection/ev3-cuboid.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-cuboid-dc93b2e60bed2981e76b3bac9ea04558.pdf)
### Check
Before you program, check:
* Are all the wires correctly connected from the motors to ports B and C?
* Are the wheels correctly installed?
* Are the wheels rotating freely?
* Are the wires connected from the Ultrasonic Sensor to port 4?
### Program
* Program your robot to detect any obstacles that might appear while the robot is moving forward (or backward).
* Make the robot stop when it detects an object that is less than 20 cm away.
Before you program, think about:
* How will you program the robot to detect obstacles?
* How will you program the robot to stop at obstacles?
* Which programming blocks will you use?
### ~hint
Consider using these blocks in your solution:
```block
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
})
motors.largeBC.steer(0, 50)
pauseUntil(() => true)
let near = sensors.ultrasonic4.distance() < 20
motors.stopAll()
```
### ~
### Sample Solution
1. Start the program when EV3 ``enter`` button is pressed.
2. Turn motors ``B`` and ``C`` on at speed ``50``.
3. Wait until Ultrasonic Sensor detects an obstacle at a distance of less than ``20`` cm.
4. Stops all motors.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 50)
pauseUntil(() => sensors.ultrasonic4.distance() < 20)
motors.stopAll()
})
```
### Download and test
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
## Contemplate
On the road, when a driver sees and object, they slow their car down before coming to a full stop.
Program your EV3 Driving Base to do the same.
If the Ultrasonic Sensor:
* Detects an object less than `10` cm away, make the robot stop.
* Detects an object between `10` and `20` cm away, make the robot slow down.
* Does not detect any object, continue to move at full speed.
### ~hint
Consider using this block in your solution:
```block
if (true) {
}
```
### ~
### Sample Solution
```blocks
loops.forever(function () {
motors.largeBC.steer(0, 50)
if (sensors.ultrasonic4.distance() < 10) {
motors.stopAll()
} else if (sensors.ultrasonic4.distance() < 20) {
motors.largeBC.steer(0, 10)
}
})
```
### Download and test
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
## Continue
* Get together with other building teams and make a traffic jam by placing all of your robots in a line with varying amounts of space between them.
* Have everyone start their robots at the same time and see what happens.
* Refine your programs so that all of the robots continue driving at the same speed with equal distances between them.
* Click on the JavaScript tab and experiment with changing the values in the code.
* Add a custom image or sounds from the Brick or Music menus.
### Share
* Share what you think “efficiency in programming” means.
* Explore the different solutions other programmers came up with.
* Create a video of your project, especially your final presentation and your robots performance. Explain some important features of your software program.
* Include an image of your program with comments.
* Add a team photograph!
Congratulations! What will you design next?

View File

@ -1,11 +1,11 @@
# Reverse Beeper Activity 1
```blocks
loops.forever(function () {
forever(function () {
music.playTone(440, sensors.ultrasonic4.distance());
loops.pause(50)
pause(50)
})
motors.largeBC.setSpeed(-20);
motors.largeBC.run(-20);
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
motors.largeBC.stop();
```

View File

@ -1,13 +1,13 @@
# Reverse Beeper Activity 2
```blocks
loops.forever(function () {
forever(function () {
if (motors.largeB.speed() != 0 && sensors.ultrasonic4.distance() < 20) {
music.playTone(440, sensors.ultrasonic4.distance());
loops.pause(50)
pause(50)
}
})
motors.largeBC.setSpeed(-20);
motors.largeBC.run(-20);
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
motors.largeBC.stop();
```

View File

@ -4,7 +4,7 @@
let beep = false
beep = true
control.runInParallel(function () {
motors.largeBC.setSpeed(-20)
motors.largeBC.run(-20)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
motors.largeBC.stop()
beep = false
@ -13,7 +13,7 @@ control.runInParallel(function () {
while (beep) {
if (sensors.ultrasonic4.distance() < 20) {
music.playTone(440, sensors.ultrasonic4.distance())
loops.pause(50)
pause(50)
}
}
})

View File

@ -2,13 +2,13 @@
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.setSpeed(50)
motors.largeBC.run(50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.setSpeed(0)
loops.pause(1000)
motors.largeBC.run(0)
pause(1000)
brick.setStatusLight(StatusLight.OrangeFlash)
motors.largeBC.setSpeed(-50)
loops.pause(2000)
motors.largeBC.setSpeed(0)
motors.largeBC.run(-50)
pause(2000)
motors.largeBC.run(0)
})
```

View File

@ -3,13 +3,13 @@
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.setSpeed(50)
motors.largeBC.run(50)
sensors.touch2.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.setSpeed(0)
loops.pause(1000)
motors.largeBC.run(0)
pause(1000)
brick.setStatusLight(StatusLight.OrangeFlash)
motors.largeBC.setSpeed(-50)
loops.pause(2000)
motors.largeBC.setSpeed(0)
motors.largeBC.run(-50)
pause(2000)
motors.largeBC.run(0)
})
```

View File

@ -5,15 +5,15 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showImage(images.eyesSleeping)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
brick.showImage(images.eyesNeutral)
motors.largeBC.setSpeed(50)
motors.largeBC.run(50)
sensors.touch2.pauseUntil(ButtonEvent.Pressed)
brick.showImage(images.eyesTiredMiddle)
motors.largeBC.setSpeed(0)
loops.pause(1000)
motors.largeBC.run(0)
pause(1000)
brick.setStatusLight(StatusLight.OrangeFlash)
brick.showImage(images.eyesDizzy)
motors.largeBC.setSpeed(-50)
loops.pause(2000)
motors.largeBC.setSpeed(0)
motors.largeBC.run(-50)
pause(2000)
motors.largeBC.run(0)
})
```

View File

@ -15,17 +15,17 @@ brick.buttonDown.onEvent(ButtonEvent.Bumped, function () {
drive.push(5)
})
pauseUntil(() => drive.length >= 5)
loops.pause(1000)
pause(1000)
music.playSoundEffectUntilDone(sounds.communicationGo)
for (let d of drive) {
if (d == 1) {
motors.largeC.setSpeed(50, 360, MoveUnit.Degrees)
motors.largeC.run(50, 360, MoveUnit.Degrees)
} else if (d == 3) {
motors.largeB.setSpeed(50, 360, MoveUnit.Degrees)
motors.largeB.run(50, 360, MoveUnit.Degrees)
} else if (d == 4) {
motors.largeBC.setSpeed(50, 360, MoveUnit.Degrees)
motors.largeBC.run(50, 360, MoveUnit.Degrees)
} else {
motors.largeBC.setSpeed(-50, 360, MoveUnit.Degrees)
motors.largeBC.run(-50, 360, MoveUnit.Degrees)
}
}
music.playSoundEffectUntilDone(sounds.communicationGameOver)

View File

@ -19,17 +19,17 @@ brick.buttonDown.onEvent(ButtonEvent.Bumped, function () {
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
loops.pause(1000)
pause(1000)
music.playSoundEffectUntilDone(sounds.communicationGo)
for (let d of drive) {
if (d == 1) {
motors.largeC.setSpeed(50, 360, MoveUnit.Degrees)
motors.largeC.run(50, 360, MoveUnit.Degrees)
} else if (d == 3) {
motors.largeB.setSpeed(50, 360, MoveUnit.Degrees)
motors.largeB.run(50, 360, MoveUnit.Degrees)
} else if (d == 4) {
motors.largeBC.setSpeed(50, 360, MoveUnit.Degrees)
motors.largeBC.run(50, 360, MoveUnit.Degrees)
} else {
motors.largeBC.setSpeed(-50, 360, MoveUnit.Degrees)
motors.largeBC.run(-50, 360, MoveUnit.Degrees)
}
}
music.playSoundEffectUntilDone(sounds.communicationGameOver)

View File

@ -3,10 +3,10 @@
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
pause(1500)
motors.largeBC.tank(-30, -75)
loops.pause(1000)
pause(1000)
motors.largeBC.tank(50, 50)
loops.pause(3000)
pause(3000)
})
```

View File

@ -3,12 +3,12 @@
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
pause(1500)
motors.largeBC.tank(-30, -75)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
motors.largeBC.tank(0, 0)
loops.pause(1000)
pause(1000)
motors.largeBC.tank(50, 50)
loops.pause(3000)
pause(3000)
})
```

View File

@ -3,13 +3,13 @@
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(75, 30)
loops.pause(1500)
pause(1500)
motors.largeBC.tank(-30, -75)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
motors.largeBC.tank(0, 0)
music.playSoundEffect(sounds.animalsDogBark1)
loops.pause(1000)
pause(1000)
motors.largeBC.tank(50, 50)
loops.pause(3000)
pause(3000)
})
```

View File

@ -3,7 +3,7 @@
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(20, 20)
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.largeBC.tank(0, 0)
})
```

View File

@ -1,7 +1,7 @@
# Traffic Lights Activity 3
```blocks
loops.forever(function () {
forever(function () {
if (sensors.color3.light(LightIntensityMode.Reflected) < 15) {
motors.largeBC.tank(30, 12)
} else {

View File

@ -0,0 +1,29 @@
# Design Engineering Projects
## Projects
```codecard
[
{
"name": "Make It Move Without Wheels",
"description": "Design, build and program a robot that can move itself using no wheels for locomotion.",
"imageUrl": "/static/lessons/make-it-move-without-wheels.png",
"url": "/design-engineering/make-it-move",
"cardType": "side"
},
{
"name": "Make It Smarter and Faster",
"description": "Design, build and program a robotic creature that can sense its environment and respond by moving.",
"imageUrl": "/static/lessons/make-it-smarter-and-faster.png",
"url": "/design-engineering/make-it-smarter",
"cardType": "side"
},
{
"name": "Make a System that Communicates",
"description": "Design, build and program a robotic system that follows a path and communicates its position at least twice along the way.",
"imageUrl": "/static/lessons/make-a-system-that-communicates.png",
"url": "/design-engineering/make-it-communicate",
"cardType": "side"
}
]
```

View File

@ -0,0 +1,151 @@
# Make A System That Communicates
## Connect
### Design Brief
Design, build and program a robotic system that follows a path and communicates its position at least twice along the way.
https://www.youtube.com/watch?v=6piMI1JPDQc
* Robotic systems are built from smaller, related subsystems. Look at the automobile system shown in the video. What subsystems can you see?
* What kinds of robots follow a path?
* What kind of system do you want to make?
### Brainstorm
Discuss different solutions to the design brief.
Think about:
* What kind of motorized mechanism can be used to control the movements of a robot?
* How can the robot sense where it is along the path?
* How can the robot communicate its position?
![EV3 + LEGO Bricks](/static/lessons/make-it-communicate/ev3-plus-parts.jpg)
## Construct
### Build
You can start by tinkering with the LEGO elements in the picture and then build on.
More building ideas:
[![EV3 Frames](/static/lessons/make-it-communicate/ev3-frames.jpg)](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/ev3%20frames-5054ee378e624fb4cb31158d2fc8e5cf.pdf)
[![Tracks](/static/lessons/make-it-communicate/ev3-tracks.jpg)](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/tracks-32d7554813af3f25cf5012d54a4bad2b.pdf)
[![Color Sensor 2](/static/lessons/make-it-communicate/ev3-color-sensor2.jpg)](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/color%20sensor_v2-e7fd54b6fa3cdfe36f414c1d2510f9cb.pdf)
Build a path for your robot to follow. You can use electrical tape on a floor, or marker on paper. You can use objects as milestones to indicate a path that can be detected by either the Touch Sensor, Color Sensor, or Ultrasonic Sensor.
### Program
Before you program, think about:
* How will you program the robot to follow a path?
* How will you program the robot to communicate its position?
* Which programming blocks will you use?
### ~hint
Explore the different Motor and Sensor blocks in the programming menu.
### ~
### Sample Solution
[![Video: EV3 Track Rover](/static/lessons/make-it-communicate/ev3-track-rover.jpg)](https://legoeducation.23video.com/v.ihtml/player.html?token=79c99735f906403a4dd7f2909935983d&source=embed&photo%5fid=19857954)
The Track Rover follows a path using the color sensor. It identifies two locations by color.
Track Rover solution combines these building ideas:
* EV3 frames
* Tracks
* Color sensor 2
Two copies of the tracks are built: one for the right side and a mirror image for the left side.
[![Track rover assembled](/static/lessons/make-it-communicate/ev3-track-rover2.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/ev3-dep/building%20instructions/track-rover-bi-6aadb1b053df0c58a0dea108b5ce0eea.pdf)
### Sample Program Solution
This program works with the Track Rover. If you create a different robot, adjust the program to fit your solution.
Program summary:
* If the Color Sensor sees black, Motor B runs at -50 power and Motor C turns off.
* If the Color Sensor sees white, Motor B turns off and Motor C runs at -50 power.
* If the Color Sensor sees green, all motors stop and the green sound plays.
* The robot waits one second, then motors move forward.
* If the Color Sensor sees red, all motors stop, and the red sound plays.
* The robot waits one second, then motors move forward.
* Loops unlimited.
```blocks
forever(function () {
if (sensors.color3.color() == ColorSensorColor.Black) {
motors.largeB.run(-50)
motors.largeC.run(0)
} else if (sensors.color3.color() == ColorSensorColor.White) {
motors.largeC.run(-50)
motors.largeB.run(0)
} else if (sensors.color3.color() == ColorSensorColor.Green) {
motors.stopAll()
music.playSoundEffectUntilDone(sounds.colorsGreen)
motors.largeBC.run(-50)
} else if (sensors.color3.color() == ColorSensorColor.Red) {
motors.stopAll()
music.playSoundEffectUntilDone(sounds.colorsRed)
motors.largeBC.run(-50)
}
})
```
### Download and test
Click Download and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Contemplate
### Test and Analyze
As you work on your solution:
1. Describe one part of your design that worked especially well.
2. Describe one design change that you had to make.
3. What will you try next?
### Review and Revise
Take a moment to reflect on your robot solution.
Think about:
* Can the robots movement be more accurate?
* What are some ways that others have solved the problem?
Describe two ways you could improve your robot.
## Continue
### Personalize your project
* Add/remove LEGO elements to improve the way your robot moves.
* Click on the JavaScript tab and experiment with changing the values in the code.
* Add a custom image or sounds by adding blocks from the Brick or Music menus.
## Communicate
Here are some ideas:
* Create a video of your project, especially your final presentation and your robots performance.
* Explain some important features of your software program.
* Produce a building guide for your model by taking a series of photographs as you deconstruct it.
* Include an image of your program with comments.
* Add a team photograph!
Congratulations! What will you design next?

View File

@ -0,0 +1,97 @@
# Make It Move Without Wheels
## Connect
### Design Brief
Design, build and program a robot that can move itself using no wheels for locomotion.
![Make it move banner](/static/lessons/make-it-move/make-it-move-without-wheels.png)
Your robot will:
* Go a distance of at least 30cm
* Use at least one motor
* Use NO wheels for locomotion
### Brainstorm
In nature, creatures use many methods to get around. None of them, however, use wheels to move. Can we copy the method of animal locomotion with our robot? Using motors and legs, make a robot that can move without using any wheels.
## Construct
### Build
Think about a creatures movement for inspiration. Will you make the robot walk, crawl, hop, or wiggle? Your mechanism can be attached or unattached to the EV3 Brick. You can start by tinkering with the LEGO elements in the picture above and then build on.
### Building Hint
If you want some building help you can follow these instructions.
[![Toddle Bot](/static/lessons/make-it-move/toddle-bot.jpg)](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/toddle%20bot-3dcad146d7f5deac4753f93e9dcc0739.pdf)
### Program
Before you program, think about:
* How will you program the robot to move?
* How will you program the robot to stop?
* How will you program the robot to display the distance moved?
Which programming blocks will you use:
* To turn on and turn off the motor or motors?
* To display the distance moved?
### Sample Code
Example code of a robot that moves without wheels using one motor:
* The robot moves with ``large motor D`` rotating at ``-100`` speed
* The robot moves for ``30000`` milliseconds (30 seconds)
* The robot stops
* The robot displays the text ``"30cm"``
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeD.run(-100)
loops.pause(30000)
motors.stopAll()
brick.showString("30cm", 1)
})
```
### Download and test
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Contemplate
### Test and Analyze
Think about:
* Is the robot using something other than wheels to move? Trace the movement from the motor axle to the mechanism(s) that drives the robot forward, backward or sideways. Wheels can be used to stabilize the robot but not to drive it.
* Does the robot display the distance moved? Is it accurate? How do you know?
* What is one part of your design that worked well?
* What is a change that you need to make?
* What will you try next?
## Continue
### Personalize your project
* Add/remove LEGO elements to improve the way your robot moves. Will your robot walk, wiggle, hop, or slither? Will it move slower, faster or farther?
* Click on the JavaScript tab and experiment with changing the values in the code.
* Add a custom image or sounds by adding blocks from the Brick or Music menus.
* Does your robot resemble a creature? Add arts and crafts materials to your project.
## Communicate
* Create a video of your project, especially your final presentation and your robots performance.
* Explain some important features of your software program.
* Produce a building guide for your model by taking a series of photographs as you deconstruct it.
* Include an image of your program with comments.
* Add a team photograph!
Congratulations! What will you design next?

View File

@ -0,0 +1,172 @@
# Make It Smarter and Faster
## Connect
### Design Brief
Design, build and program a robotic creature that can sense its environment and respond by moving.
https://www.youtube.com/watch?v=y9-A_C_08KY
* What do the robots in the video need to be able to sense, plan, and act?
* What senses do humans have and why are they important to us?
* How many human-like senses do you see the robots demonstrating?
### Brainstorm
Discuss different solutions to the design brief.
Think about:
* What kind of creature can it be?
* How can it move?
* What does it need to be aware so that it stays safe, well fed and warm (or cool)?
* Is it looking for food, a safe place to hide or a warm place to soak up the sun?
* Will the creature need to move fast or slow?
* Will it need to turn?
* Will it need to go backward?
![EV3 and bricks](/static/lessons/make-it-smarter/bricks.png)
## Construct
### Build
Think about a creatures movement for inspiration. Your mechanism can be attached or unattached to the EV3 Brick. You can start by tinkering with the LEGO elements in the picture add then build on.
More building ideas:
| | | | | |
|-|-|-|-|-|
|[![EV3 Frames](/static/lessons/make-it-smarter/ev3-parts-frames.jpg)][EV3 Frames] | |[![EV3 Color Sensor 1](/static/lessons/make-it-smarter/ev3-parts-color-sensor-1.jpg)][Color Sensor 1] | |[![EV3 Gyro Sensor](/static/lessons/make-it-smarter/ev3-parts-gyro-sensor.jpg)][Gyro Sensor] |
| [EV3 Frames] | | [Color Sensor 1] | | [Gyro Sensor] |
<br/>
| | | | | |
|-|-|-|-|-|
|[![EV3 Ultrasonic Sensor](/static/lessons/make-it-smarter/ev3-parts-ultrasonic-sensor.jpg)][Ultrasonic Sensor] | | [![EV3 Touch Sensor](/static/lessons/make-it-smarter/ev3-parts-touch-sensor.jpg)][Touch Sensor] | | [![EV3 Gyro Sensor](/static/lessons/make-it-smarter/ev3-parts-jaw.jpg)][Jaw] |
| [Ultrasonic Sensor] | | [Touch Sensor] | | [Jaw] |
<br/>
| | | | | |
|-|-|-|-|-|
| [![EV3 Leg 1](/static/lessons/make-it-smarter/ev3-parts-leg-1.jpg)][Leg 1] | | [![EV3 Leg 2](/static/lessons/make-it-smarter/ev3-parts-leg-2.jpg)][Leg 2] | | [![EV3 Leg 3](/static/lessons/make-it-smarter/ev3-parts-leg-3.jpg)][Leg 3] |
| [Leg 1] | | [Leg 2] | | [Leg 3] |
### Program
Before you program, think about:
* How will you program the robot to sense?
* How will you program the robot to respond?
* Which programming blocks will you use?
### ~hint
**Hint:** Explore the different Sensor blocks in the Sensors Menu
### ~
### Sample Solution
The Insect uses its Ultrasonic Sensor to sense danger and move away from a threat.
https://www.youtube.com/watch?v=PoeYoiXHHE4
<br/>
The Insect solution combines these building ideas:
* [EV3 Frames]
* [Leg 2]
* [Leg 3]
* [Ultrasonic Sensor]
Four copies of Leg 3 are built: one for the front left, one for the back right, and two mirror copies for the front right and back left.
Building Instructions:
[![Insect robot](/static/lessons/make-it-smarter/insect-bot.jpg)](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/insect-94b8a46f0dc5082c9d78ddb734626dc9.pdf)
### Sample Solution
This program checks if the Ultrasonic Sensor senses something near.
The blocks inside the ``||loops:forever||`` loop have these actions:
1. Turn on the ``green`` EV3 Brick Status Light.
2. Wait for Ultrasonic Sensor to detect an object.
3. Turn on Motors ``A`` and ``D`` in opposite directions.
4. Wait for one quarter of a second (``1500`` milli seconds).
5. Reverse the direction of Motors ``A`` and ``D``.
6. Wait for one quarter of a second.
7. Stop all motors.
8. Make an insect chirping sound.
9. Loop continuously so that the insect wanders around when the Ultrasonic Sensor is detects something.
```blocks
forever(function () {
brick.setStatusLight(StatusLight.Green)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected)
motors.largeAD.tank(50, -50)
pause(1500)
motors.largeAD.tank(-50, 50)
pause(1500)
motors.stopAll()
music.playSoundEffectUntilDone(sounds.animalsInsectChirp)
})
```
### Download and test
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Contemplate
### Test and Analyze
As you work on your solution:
1. Describe one part of your design that worked especially well.
2. Describe one design change that you had to make.
3. What will you try next?
### Review and Revise
Take a moment to reflect on your robot solution.
Think about:
* Does your robot move when the sensor is activated?
* If not, what will you change to make the robots ability to sense and respond more obvious?
* What other behaviors can you add to the robot to make it more realistic?
Describe two ways you could improve your robot.
## Continue
Personalize your project:
* Add/remove LEGO elements to improve the way your robot moves.
* Click on the JavaScript tab and experiment with changing the values in the code.
* Add a custom image or sounds by adding blocks from the Brick or Music menus.
* Does your robot resemble a creature? Maybe add more craft materials to your project.
## Communicate
Here are some ideas:
* Create a video of your project, especially your final presentation and your robots performance. Explain some important features of your software program.
* Produce a building guide for your model by taking a series of photographs as you deconstruct it.
* Include an image of your program with comments.
* Add a team photograph!
Congratulations! What will you design next?
[EV3 Frames]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/ev3%20frames-5054ee378e624fb4cb31158d2fc8e5cf.pdf
[Color Sensor 1]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/color%20sensor_v1-16a7231bdc187cd88a8da120c68f58d5.pdf
[Gyro Sensor]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/gyro%20sensor-6f0fdbd82ae45fe0effa0ebf3f460f3d.pdf
[Ultrasonic Sensor]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/ultrasonic%20sensor-a56156c72e8946ed4c58c5e69f3520d3.pdf
[Touch Sensor]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/touch%20sensor-868fda1b9d6070a0a034fb22456a7fc9.pdf
[Jaw]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/jaw-ee93e8f3243e4d30cd34b0c337c33653.pdf
[Leg 1]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/leg%201-c14624046ea3a95148820ed404f5ac65.pdf
[Leg 2]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/leg%202-8855c35b990205f6b9d7130687a3d4db.pdf
[Leg 3]: https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/leg%203-575d52ef15fb79f1e4d3350d36607160.pdf

View File

@ -2,6 +2,207 @@
Here are some fun programs for your @boardname@!
## Maker
```codecard
[
{
"name": "Sound Of Color",
"description": "Play different sounds based on the color",
"url":"/maker/sound-of-color",
"cardType": "example",
"imageUrl": "/static/maker/sound-of-color.png"
},
{
"name": "Security Gadget",
"description": "Raise the alarm when your brick is lifted!",
"url":"/maker/security-gadget",
"cardType": "example",
"imageUrl": "/static/maker/security-gadget.png"
},
{
"name": "Movement Detector",
"description": "Raise the alarm when an movement sneaks in",
"url":"/maker/movement-detector",
"cardType": "example",
"imageUrl": "/static/maker/movement-detector.png"
},
{
"name": "Puppet",
"description": "Build an automated puppet",
"url":"/maker/puppet",
"cardType": "example",
"imageUrl": "/static/maker/puppet.png"
}
]
```
## Three Point Turn
```codecard
[
{
"name": "Three Point Turn 1",
"description": "Activity 1",
"url":"/coding/three-point-turn-1",
"cardType": "example"
}, {
"name": "Three Point Turn 2",
"description": "Activity 2",
"url":"/coding/three-point-turn-2",
"cardType": "example"
}, {
"name": "Three Point Turn 3",
"description": "Activity 3",
"url":"/coding/three-point-turn-3",
"cardType": "example"
}]
```
## Reversing the robot
```codecard
[{
"name": "Reversing the robot 1",
"description": "Activity 1",
"url":"/coding/reversing-the-robot-1",
"cardType": "example"
}, {
"name": "Reversing the robot 2",
"description": "Activity 2",
"url":"/coding/reversing-the-robot-2",
"cardType": "example"
}, {
"name": "Reversing the robot 3",
"description": "Activity 3",
"url":"/coding/reversing-the-robot-3",
"cardType": "example"
}]
```
## Light the way
```codecard
[{
"name": "Light the way 1",
"description": "Activity 1",
"url":"/coding/light-the-way-1",
"cardType": "example"
}, {
"name": "Light the way 2",
"description": "Activity 2",
"url":"/coding/light-the-way-2",
"cardType": "example"
}, {
"name": "Light the way 3",
"description": "Activity 3",
"url":"/coding/light-the-way-3",
"cardType": "example"
}
]
```
## Traffic Lights
```codecard
[{
"name": "Traffic Lights 1",
"description": "Activity 1",
"url":"/coding/traffic-lights-1",
"cardType": "example"
}, {
"name": "Traffic Lights 2",
"description": "Activity 2",
"url":"/coding/traffic-lights-2",
"cardType": "example"
}, {
"name": "Traffic Lights 3",
"description": "Activity 3",
"url":"/coding/traffic-lights-3",
"cardType": "example"
}
]
```
## Reverse Bepper
```codecard
[{
"name": "Reverse Beeper 1",
"description": "Activity 1",
"url":"/coding/reverse-beeper-1",
"cardType": "example"
}, {
"name": "Reverse Beeper 2",
"description": "Activity 2",
"url":"/coding/reverse-beeper-2",
"cardType": "example"
}, {
"name": "Reverse Beeper 3",
"description": "Activity 3",
"url":"/coding/reverse-beeper-3",
"cardType": "example"
}]
```
## Ignition
```codecard
[{
"name": "Ignition 1",
"description": "Activity 1",
"url":"/coding/ingition-1",
"cardType": "example"
}, {
"name": "Ignition 2",
"description": "Activity 2",
"url":"/coding/ignition-2",
"cardType": "example"
}, {
"name": "Ignition 3",
"description": "Activity 3",
"url":"/coding/ignition-3",
"cardType": "example"
}]
```
## Cruise Control
```codecard
[{
"name": "Cruise Control 1",
"description": "Activity 1",
"url":"/coding/cruise-control-1",
"cardType": "example"
}, {
"name": "Cruise Control 2",
"description": "Activity 2",
"url":"/coding/cruise-control-2",
"cardType": "example"
}, {
"name": "Cruise Control 3",
"description": "Activity 3",
"url":"/coding/cruise-control-3",
"cardType": "example"
}]
```
## Roaming
```codecard
[{
"name": "Roaming 1",
"description": "Activity 1",
"url":"/coding/roaming-1",
"cardType": "example"
}, {
"name": "Roaming 2",
"description": "Activity 2",
"url":"/coding/roaming-2",
"cardType": "example"
}]
```
## Fun stuff
```codecard
@ -11,5 +212,10 @@ Here are some fun programs for your @boardname@!
"description": "Keep your brick entertained and happy",
"url":"/examples/happy-unhappy",
"cardType": "example"
}, {
"name": "Distance Measurer",
"description": "Use a motor to measure angle and distance",
"url": "/examples/distance-measurer",
"cardType": "example"
}]
```

View File

@ -108,7 +108,7 @@ function checkFallen() {
// stop all motors and wait for touch button to be
// pressed
function stop() {
motors.stopAllMotors()
motors.stopAll()
state = 0
moods.knockedOut.show();
sensors.touch3.pauseUntil(ButtonEvent.Pressed)
@ -119,15 +119,15 @@ sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () {
controlSteering = 0
oldControlDrive = controlDrive
controlDrive = -10
motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees);
motors.mediumC.setSpeed(-30, 60, MoveUnit.Degrees);
motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees);
motors.mediumC.run(30, 30, MoveUnit.Degrees);
motors.mediumC.run(-30, 60, MoveUnit.Degrees);
motors.mediumC.run(30, 30, MoveUnit.Degrees);
if (Math.randomRange(-1, 1) >= 1) {
controlSteering = 70
} else {
controlSteering = -70
}
loops.pause(4000)
pause(4000)
music.playTone(2000, 100)
controlSteering = 0
controlDrive = oldControlDrive
@ -149,8 +149,8 @@ sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {
})
// apply power to motors
function controlMotors() {
motors.largeA.setSpeed(power + controlSteering * 0.1)
motors.largeD.setSpeed(power - controlSteering * 0.1)
motors.largeA.run(power + controlSteering * 0.1)
motors.largeD.run(power - controlSteering * 0.1)
}
sensors.color1.onColorDetected(ColorSensorColor.Yellow, function () {
moods.middleLeft.show()
@ -162,7 +162,7 @@ sensors.color1.onColorDetected(ColorSensorColor.White, function () {
})
timestep = 0.014
// main loop
loops.forever(function () {
forever(function () {
reset()
while (!fallen) {
control.timer3.pauseUntil(5)

View File

@ -36,7 +36,7 @@ function RST() {
sensors.gyro2.reset()
sensors.gyro2.rate()
control.timer2.reset()
loops.pause(5000)
pause(5000)
mSum = 0;
mPos = 0;
mD = 0;
@ -65,7 +65,7 @@ function OS() {
gSum = gyro;
gMx = Math.max(gMx, gyro)
gMn = Math.min(gMn, gyro)
loops.pause(4);
pause(4);
}
} while (gMx - gMn > 2);
gOS = gSum / 200;
@ -121,7 +121,7 @@ function CHK() {
}
// M
loops.forever(function () {
forever(function () {
RST();
brick.showImage(images.eyesSleeping)
OS()
@ -137,14 +137,14 @@ loops.forever(function () {
GM();
EQ();
cntrl();
motors.largeA.setSpeed(lpwr)
motors.largeD.setSpeed(rpwr)
motors.largeA.run(lpwr)
motors.largeD.run(rpwr)
CHK()
let t2 = control.timer1.millis();
let p = 5 - (t2 - t1);
loops.pause(Math.max(1, p))
pause(Math.max(1, p))
}
motors.stopAllMotors()
motors.stopAll()
st = 0;
brick.setStatusLight(StatusLight.RedPulse);
brick.showImage(images.eyesKnockedOut)
@ -154,7 +154,7 @@ loops.forever(function () {
})
// BHV
loops.forever(function () {
forever(function () {
switch (st) {
case 0:
Cdrv = 0;
@ -162,7 +162,7 @@ loops.forever(function () {
break;
case 1:
Cdrv = 40;
loops.pause(4000);
pause(4000);
Cdrv = 0;
music.playTone(1000, 100);
st = 2;
@ -196,20 +196,20 @@ loops.forever(function () {
Cstr = 0;
oldDr = Cdrv;
Cdrv = -10;
motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees);
motors.mediumC.setSpeed(-30, 60, MoveUnit.Degrees);
motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees);
motors.mediumC.run(30, 30, MoveUnit.Degrees);
motors.mediumC.run(-30, 60, MoveUnit.Degrees);
motors.mediumC.run(30, 30, MoveUnit.Degrees);
if (Math.randomRange(-1, 1) >= 1)
Cstr = 70;
else
Cstr = -70;
loops.pause(4000);
pause(4000);
music.playTone(2000, 100)
Cstr = 0;
Cdrv = oldDr;
}
break;
}
loops.pause(80);
pause(80);
})
```

View File

@ -21,7 +21,7 @@ let GTO = 0;
function DN() {
motors.largeAD.setBrake(true);
motors.largeAD.tank(50, 50, 1, MoveUnit.Seconds);
loops.pause(100);
pause(100);
motors.largeA.clearCounts()
motors.largeD.clearCounts()
}
@ -32,9 +32,9 @@ function MNRH() {
brick.setStatusLight(StatusLight.OrangePulse)
while (!brick.buttonEnter.wasPressed()) {
if (brick.buttonUp.wasPressed()) {
motors.mediumC.setSpeed(-100);
motors.mediumC.run(-100);
} else if (brick.buttonDown.wasPressed()) {
motors.mediumC.setSpeed(100);
motors.mediumC.run(100);
} else {
motors.mediumC.stop();
}
@ -83,24 +83,24 @@ function UP() {
if (motors.largeA.angle() > -50) {
control.runInParallel(function () {
motors.largeD.clearCounts()
motors.largeD.setSpeed(-35);
motors.largeD.run(-35);
pauseUntil(() => motors.largeD.angle() < -25);
motors.largeD.stop();
motors.largeD.setRegulated(false)
motors.largeD.setSpeed(-15)
motors.largeD.run(-15)
pauseUntil(() => motors.largeD.angle() < -65);
motors.largeD.stop();
})
motors.largeA.clearCounts()
motors.largeA.setSpeed(-35);
motors.largeA.run(-35);
pauseUntil(() => motors.largeA.angle() < -25);
motors.largeA.stop();
motors.largeA.setRegulated(false)
motors.largeA.setSpeed(-15)
motors.largeA.run(-15)
pauseUntil(() => motors.largeA.angle() < -65);
motors.largeA.stop();
loops.pause(500);
pause(500);
}
}
@ -231,9 +231,9 @@ function IDL() {
function MHT(Pos: number) {
let _R = Pos - motors.mediumC.angle();
if (_R >= 0) {
motors.mediumC.setSpeed(100, _R, MoveUnit.Degrees);
motors.mediumC.run(100, _R, MoveUnit.Degrees);
} else {
motors.mediumC.setSpeed(-100, Math.abs(_R), MoveUnit.Degrees);
motors.mediumC.run(-100, Math.abs(_R), MoveUnit.Degrees);
}
}
@ -277,7 +277,7 @@ function NGR() {
IS(4)
music.playSoundEffect(sounds.animalsDogGrowl);
UP();
loops.pause(1500);
pause(1500);
music.stopAllSounds()
music.playSoundEffect(sounds.animalsDogBark1)
P_C--;
@ -303,16 +303,16 @@ function PPP() {
NS = false;
IS(2);
UP();
loops.pause(100)
motors.largeA.setSpeed(-30, 70, MoveUnit.Degrees);
loops.pause(800);
pause(100)
motors.largeA.run(-30, 70, MoveUnit.Degrees);
pause(800);
music.playSoundEffect(sounds.mechanicalHorn1);
loops.pause(1000);
pause(1000);
for(let i = 0; i < 3; ++i) {
motors.largeA.setSpeed(-30, 20, MoveUnit.Degrees);
motors.largeA.setSpeed(30, 20, MoveUnit.Degrees);
motors.largeA.run(-30, 20, MoveUnit.Degrees);
motors.largeA.run(30, 20, MoveUnit.Degrees);
}
motors.largeA.setSpeed(30, 70, MoveUnit.Degrees);
motors.largeA.run(30, 70, MoveUnit.Degrees);
F_C = 1;
CS(0);
}
@ -320,14 +320,14 @@ function PPP() {
function HPY() {
IS(8)
MHT(0);
motors.largeAD.setSpeed(10, 0.8, MoveUnit.Seconds);
motors.largeAD.run(10, 0.8, MoveUnit.Seconds);
for(let i = 0; i < 3; ++i) {
music.playSoundEffect(sounds.animalsDogBark1);
motors.largeAD.setSpeed(-100, 0.2, MoveUnit.Seconds);
loops.pause(300)
motors.largeAD.setSpeed(10, 0.3, MoveUnit.Seconds)
motors.largeAD.run(-100, 0.2, MoveUnit.Seconds);
pause(300)
motors.largeAD.run(10, 0.3, MoveUnit.Seconds)
}
loops.pause(500);
pause(500);
music.stopAllSounds();
DN();
RST();
@ -335,9 +335,9 @@ function HPY() {
function STL() {
UP();
motors.largeAD.setSpeed(-20, 60, MoveUnit.Degrees);
motors.largeAD.run(-20, 60, MoveUnit.Degrees);
music.playSoundEffect(sounds.animalsDogWhine);
motors.largeAD.setSpeed(20, 60, MoveUnit.Degrees);
motors.largeAD.run(20, 60, MoveUnit.Degrees);
}
function WKU() {
@ -347,7 +347,7 @@ function WKU() {
MHT(0)
DN()
STL()
loops.pause(1000);
pause(1000);
UP()
CS(0;)
}
@ -358,7 +358,7 @@ MNRH();
IS(1);
UP();
RST();
loops.forever(function () {
forever(function () {
MON();
switch (DB_S) {
case 0:

View File

@ -5,20 +5,20 @@ function INI() {
motors.largeB.setBrake(true)
motors.largeC.setBrake(true)
motors.mediumA.setBrake(true)
motors.largeB.setSpeed(-50)
motors.largeB.run(-50)
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop();
motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds);
motors.mediumA.setSpeed(-50, 90, MoveUnit.Degrees);
motors.largeC.setSpeed(50)
motors.mediumA.run(30, 1, MoveUnit.Seconds);
motors.mediumA.run(-50, 90, MoveUnit.Degrees);
motors.largeC.run(50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed);
motors.largeC.setSpeed(-50, 0.86, MoveUnit.Rotations);
motors.largeC.run(-50, 0.86, MoveUnit.Rotations);
}
INI()
let down = false;
loops.forever(function () {
forever(function () {
brick.showImage(images.informationQuestionMark)
brick.setStatusLight(StatusLight.OrangePulse);
pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed())
@ -27,24 +27,24 @@ loops.forever(function () {
brick.showImage(images.informationAccept)
if (down) {
brick.showImage(images.informationForward)
motors.largeC.setSpeed(65, 0.85, MoveUnit.Rotations);
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
} else {
brick.showImage(images.informationBackward)
motors.largeC.setSpeed(-65, 0.85, MoveUnit.Rotations);
motors.largeC.run(-65, 0.85, MoveUnit.Rotations);
}
motors.largeB.setSpeed(20, 275, MoveUnit.Degrees)
motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds)
motors.largeB.setSpeed(-55)
motors.largeB.run(20, 275, MoveUnit.Degrees)
motors.mediumA.run(30, 1, MoveUnit.Seconds)
motors.largeB.run(-55)
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop();
if (down) {
motors.largeC.setSpeed(-65, 0.86, MoveUnit.Rotations);
motors.largeC.run(-65, 0.86, MoveUnit.Rotations);
} else {
motors.largeC.setSpeed(65, 0.85, MoveUnit.Rotations);
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
}
motors.largeB.setSpeed(20, 275, MoveUnit.Degrees);
motors.mediumA.setSpeed(-30, 90, MoveUnit.Degrees);
motors.largeB.setSpeed(-55)
motors.largeB.run(20, 275, MoveUnit.Degrees);
motors.mediumA.run(-30, 90, MoveUnit.Degrees);
motors.largeB.run(-55)
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop()
})

View File

@ -5,20 +5,20 @@ function INI() {
motors.largeB.setBrake(true)
motors.largeC.setBrake(true)
motors.mediumA.setBrake(true)
motors.largeB.setSpeed(-50)
motors.largeB.run(-50)
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop();
motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds);
motors.mediumA.setSpeed(-50, 90, MoveUnit.Degrees);
motors.largeC.setSpeed(50)
motors.mediumA.run(30, 1, MoveUnit.Seconds);
motors.mediumA.run(-50, 90, MoveUnit.Degrees);
motors.largeC.run(50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed);
motors.largeC.setSpeed(-50, 0.86, MoveUnit.Rotations);
motors.largeC.run(-50, 0.86, MoveUnit.Rotations);
}
INI()
let down = false;
loops.forever(function () {
forever(function () {
brick.showImage(images.informationQuestionMark)
brick.setStatusLight(StatusLight.OrangePulse);
pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed())
@ -27,24 +27,24 @@ loops.forever(function () {
brick.showImage(images.informationAccept)
if (down) {
brick.showImage(images.informationForward)
motors.largeC.setSpeed(65, 0.85, MoveUnit.Rotations);
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
} else {
brick.showImage(images.informationBackward)
motors.largeC.setSpeed(-65, 0.85, MoveUnit.Rotations);
motors.largeC.run(-65, 0.85, MoveUnit.Rotations);
}
motors.largeB.setSpeed(20, 275, MoveUnit.Degrees)
motors.mediumA.setSpeed(30, 1, MoveUnit.Seconds)
motors.largeB.setSpeed(-55)
motors.largeB.run(20, 275, MoveUnit.Degrees)
motors.mediumA.run(30, 1, MoveUnit.Seconds)
motors.largeB.run(-55)
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop();
if (down) {
motors.largeC.setSpeed(-65, 0.86, MoveUnit.Rotations);
motors.largeC.run(-65, 0.86, MoveUnit.Rotations);
} else {
motors.largeC.setSpeed(65, 0.85, MoveUnit.Rotations);
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
}
motors.largeB.setSpeed(20, 275, MoveUnit.Degrees);
motors.mediumA.setSpeed(-30, 90, MoveUnit.Degrees);
motors.largeB.setSpeed(-55)
motors.largeB.run(20, 275, MoveUnit.Degrees);
motors.mediumA.run(-30, 90, MoveUnit.Degrees);
motors.largeB.run(-55)
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop()
})

View File

@ -0,0 +1,34 @@
# Distance Measurer
```blocks
let distance = 0
let angle = 0
let measuring = false
let radius = 0
// Start and stop measuring with the enter button
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
if (measuring) {
// turn off the measuring
measuring = false
brick.setStatusLight(StatusLight.Off)
} else {
// turn on the measuring clear the counters so that
// the motor tracks the angle
measuring = true
motors.largeB.clearCounts()
brick.setStatusLight(StatusLight.GreenPulse)
}
})
radius = 2.5
brick.showString("Press ENTER to measure", 4)
forever(function () {
if (measuring) {
angle = motors.largeB.angle()
distance = angle / 180 * Math.PI * radius
brick.clearScreen()
brick.showValue("angle", angle, 2)
brick.showValue("distance", distance, 3)
}
pause(100)
})
```

View File

@ -36,7 +36,7 @@ function RST() {
sensors.gyro2.reset()
sensors.gyro2.rate()
control.timer2.reset()
loops.pause(5000)
pause(5000)
mSum = 0;
mPos = 0;
mD = 0;
@ -65,7 +65,7 @@ function OS() {
gSum = gyro;
gMx = Math.max(gMx, gyro)
gMn = Math.min(gMn, gyro)
loops.pause(4);
pause(4);
}
} while (gMx - gMn > 2);
gOS = gSum / 200;
@ -121,7 +121,7 @@ function CHK() {
}
// M
loops.forever(function () {
forever(function () {
RST();
brick.showImage(images.eyesSleeping)
OS()
@ -137,14 +137,14 @@ loops.forever(function () {
GM();
EQ();
cntrl();
motors.largeA.setSpeed(lpwr)
motors.largeD.setSpeed(rpwr)
motors.largeA.run(lpwr)
motors.largeD.run(rpwr)
CHK()
let t2 = control.timer1.millis();
let p = 5 - (t2 - t1);
loops.pause(Math.max(1, p))
pause(Math.max(1, p))
}
motors.stopAllMotors()
motors.stopAll()
st = 0;
brick.setStatusLight(StatusLight.RedPulse);
brick.showImage(images.eyesKnockedOut)
@ -154,7 +154,7 @@ loops.forever(function () {
})
// BHV
loops.forever(function () {
forever(function () {
switch (st) {
case 0:
Cdrv = 0;
@ -162,7 +162,7 @@ loops.forever(function () {
break;
case 1:
Cdrv = 40;
loops.pause(4000);
pause(4000);
Cdrv = 0;
music.playTone(1000, 100);
st = 2;
@ -196,20 +196,20 @@ loops.forever(function () {
Cstr = 0;
oldDr = Cdrv;
Cdrv = -10;
motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees);
motors.mediumC.setSpeed(-30, 60, MoveUnit.Degrees);
motors.mediumC.setSpeed(30, 30, MoveUnit.Degrees);
motors.mediumC.run(30, 30, MoveUnit.Degrees);
motors.mediumC.run(-30, 60, MoveUnit.Degrees);
motors.mediumC.run(30, 30, MoveUnit.Degrees);
if (Math.randomRange(-1, 1) >= 1)
Cstr = 70;
else
Cstr = -70;
loops.pause(4000);
pause(4000);
music.playTone(2000, 100)
Cstr = 0;
Cdrv = oldDr;
}
break;
}
loops.pause(80);
pause(80);
})
```

View File

@ -14,7 +14,7 @@ v = sensors.color3.light(LightIntensityMode.Reflected)
min = v
max = v
setpoint = v
while (!(brick.buttonEnter.wasPressed())) {
while (!(brick.buttonEnter.isPressed())) {
brick.clearScreen()
brick.showString("Move robot on terrain", 1)
brick.showString("Press ENTER when done", 2)
@ -26,9 +26,9 @@ while (!(brick.buttonEnter.wasPressed())) {
brick.showValue("min", min, 4)
brick.showValue("max", v, 5)
brick.showValue("setpoint", setpoint, 6)
loops.pause(100)
pause(100)
}
loops.forever(function () {
forever(function () {
brick.clearScreen()
v = sensors.color3.light(LightIntensityMode.Reflected)
brick.showValue("light", v, 1)
@ -43,7 +43,7 @@ loops.forever(function () {
motors.largeBC.steer(P + (I + D), 100)
lasterror = error
if (brick.buttonEnter.wasPressed()) {
motors.largeBC.setSpeed(0)
motors.largeBC.run(0)
brick.buttonDown.pauseUntil(ButtonEvent.Bumped)
}
})

View File

@ -1,40 +0,0 @@
# Print Ports
```typescript
/**
* Print the port states on the screen
*/
//% blockId=brickPrintPorts block="print ports"
//% help=brick/print-ports
//% weight=1 group="Screen"
function printPorts() {
const col = 44;
clearScreen();
function scale(x: number) {
if (Math.abs(x) > 1000) return Math.round(x / 100) / 10 + "k";
return ("" + (x >> 0));
}
// motors
const datas = motors.getAllMotorData();
for(let i = 0; i < datas.length; ++i) {
const data = datas[i];
if (!data.actualSpeed && !data.count) continue;
const x = i * col;
print(`${scale(data.actualSpeed)}%`, x, brick.LINE_HEIGHT)
print(`${scale(data.count)}>`, x, 2 * brick.LINE_HEIGHT)
print(`${scale(data.tachoCount)}|`, x, 3 * brick.LINE_HEIGHT)
}
// sensors
const sis = sensors.internal.getActiveSensors();
for(let i =0; i < sis.length; ++i) {
const si = sis[i];
const x = (si.port() - 1) * col;
const v = si._query();
print(`${scale(v)}`, x, 9 * brick.LINE_HEIGHT)
}
}
```

30
docs/getting-started.md Normal file
View File

@ -0,0 +1,30 @@
# Getting Started
## Projects
```codecard
[
{
"name": "Prepare",
"imageUrl": "/static/lessons/firmware.png",
"description": "To use Microsoft MakeCode with your EV3 Brick, you will need to install the latest LEGO MINDSTORMS Education EV3 firmware - version 1.10 or higher. Follow these steps to install the latest firmware from LEGO.",
"label": "New? Start Here!",
"labelClass": "red ribbon large",
"url": "https://makecode.mindstorms.com/troubleshoot"
},
{
"name": "Try",
"imageUrl": "/static/lessons/try.png",
"description": "Get a quick introduction to programming.",
"url": "/getting-started/try",
"cardType": "side"
},
{
"name": "Use",
"imageUrl": "/static/lessons/use.png",
"description": "Build a robot and drive into the world of robotics!",
"url": "/getting-started/use",
"cardType": "side"
}
]
```

165
docs/getting-started/try.md Normal file
View File

@ -0,0 +1,165 @@
# Try
Get a quick introduction to programming with EV3.
![Display on EV3 Brick with Music Notes](/static/getting-started/01_EyesOn_Intro.png)
We are excited to help you get started with @boardname@. In this project we will guide you through connecting your EV3 Brick, creating your first program, controlling a Large Motor, a Touch Sensor and a Color Sensor. These steps can take up to 45 minutes.
## Turn on your EV3 Brick
Power on your EV3 Brick by pressing the Center Button.
![Hand pressing power button](/static/getting-started/02_PowerOn.png)
## Connect Your EV3 Brick to Your Device
Use the USB cable to connect your EV3 Brick to your device.
![Computer and cable connected to EV3 Brick](/static/getting-started/03_insert-usb-02.png)
## Create and Run your First Program
**Code it:** Create the program shown here.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
brick.showMood(moods.neutral)
music.playSoundEffect(sounds.communicationHello)
})
```
* Drag out a ``||brick:on button||`` block from Buttons section in the ``||brick:Brick||`` Toolbox drawer.
* Drag a Brick Screen ``||brick:show mood||`` block inside the ``||brick:on button||`` block.
* Change mood to ``neutral``.
```block
brick.showMood(moods.neutral)
```
* Drag a Music ``||music:play sound effect||`` block below the ``||brick:show mood||`` block.
* Change sound effect to ``communication hello``.
```block
music.playSoundEffect(sounds.communicationHello)
```
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Did It Work?
![EV3 Brick with eyes on the display](/static/getting-started/05_EyesOn.png)
Verify that the program you just created shows eyes on the Brick Display, and that the EV3 Brick played the sound “Hello!”
**Well done!**
## Connect a Large Motor
Now you will learn to control the Large Motor.
![EV3 Brick with hands connecting Large Motor to Port D](/static/getting-started/06_PlugInLargeMotor.png)
Connect a Large Motor to **Port D** of your EV3 Brick using any of the connector cables.
## Create and Run This Program
**Code it:** Create the program shown here.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeD.run(50, 1, MoveUnit.Rotations)
})
```
* Start a new program.
* Drag a ``||motors:run large A motor||`` block inside the ``||brick:on button||`` block.
* Change ``large motor A`` to ``large motor D``.
* Click on the **(+)** sign.
* Change to ``1`` rotation.
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Did It Rotate?
Confirm that your motor has turned one rotation at power level 50 before stopping.
![Large Motor D w/Rotating “WHRRR,” Hand, EV3 Brick](/static/getting-started/08_WorkingLargeMotor.png)
Download and run the program as many times as you want in order to verify this, or tinker with different power levels and different rotations.
## Connect a Touch Sensor
We will now control the Large Motor using a Touch Sensor.
![Hands connecting Touch Sensor to Port 1 on EV3 Brick](/static/getting-started/09_Connect_Touch.png)
Keeping the Large Motor connected to **Port D**, connect a Touch Sensor to **Port 1** of your EV3 Brick.
## Modify Your Program
**Code it:** Add code to the program for the Touch Sensor.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeD.run(50, 1, MoveUnit.Rotations)
})
```
* Add a ``||sensors:pause until touch 1 pressed||`` Sensor block on top of the ``||motors:run large motor D||`` block.
```block
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
```
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Press the Touch Sensor
Confirm that the Large Motor has turned one rotation AFTER you press the Touch Sensor.
![Hand Touch Sensor Pressed & EV3 Brick & Large Motor](/static/getting-started/11_TouchMotorWorking.png)
Download and run the program as many times as you want in order to verify this, or tinker with different Touch Sensor and Large Motor values.
## Connect a Color Sensor
Now we will try to control the Large Motor using another sensor.
![Hand connecting Color Sensor to Port 4, Large Motor D, EV3 Brick](/static/getting-started/12_ConnectColor.png)
Keeping the Large Motor connected to **Port D**, connect the Color Sensor to **Port 4**.
**Code it:** Modify Your Program to use the Color Sensor.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
motors.largeD.run(50, 1, MoveUnit.Rotations)
})
```
* Using the same program, replace the ``||sensors:pause until touch 1||`` block with a ``||sensors:pause color sensor 3||`` for color block.
```block
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
```
* Select the color you want to detect (e.g., green).
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Place a Colored Brick in Front of the Color Sensor
![IMG: Colored bricks in front of Color Sensor, hands, EV3 Brick](/static/getting-started/14_ColorSensorWorking.png)
Confirm that the Large Motor has turned one rotation AFTER the Color Sensor has detected the colored brick.
Download and run the program as many times as you want in order to verify this, or tinker with different Color Sensor and Large Motor values.
Click on the **JavaScript** tab and change the color the Color Sensor detects to Black, Blue, Green, Yellow, Red, White, or Brown. Use Title Case for the color names.
## Well Done!
You have now learned how to control some of the inputs and outputs of the EV3.

109
docs/getting-started/use.md Normal file
View File

@ -0,0 +1,109 @@
# Use
Build a robot and drive into the world of robotics!
![EV3 Driving Base full w/cuboid](/static/getting-started/EV3_GettingStarted_13.jpg)
In this project we will guide you through building a Driving Base Robot and programming it to move straight and turn. You will also build and Object Detector Module, and program it to detect an object. Its a good idea to have done the [Try](/getting-started/try) sequence first.
## Connect
What if your school had a multipurpose robot? How would you use it?
![Apple Picker Robot](/static/getting-started/02_ApplePickerRobot.jpg)
Would you use it to clean the school or plant trees?
## Build Your Driving Base Robot
Build the robot driving base:
[![EV3 Driving Base](/static/lessons/common/ev3-driving-base.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf)
## Make It Move
**Code it:** Create a program that makes the Driving Base move forward and stop at the finish line, which is ``1`` meter away.
Start by building this program:
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations)
})
```
* Drag a ``||motors:steer large motors B+C||`` block inside an ``||brick:on button||`` block.
* Click on the **(+)** sign.
* Change to ``1`` rotation.
### ~hint
**Hint:** You will have to modify the number of rotations until you find the number that matches the robot moving forward 1 meter and stopping.
### ~
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Make It Turn
**Code it:** Create a new program that turns the Driving Base 180 degrees.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(-50, 50, 1, MoveUnit.Rotations)
})
```
### ~hint
**Hint:** You will have to modify the turn ratio and the number of rotations until the robot reaches 180 degrees.
### ~
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
## Add an Ultrasonic Sensor to Your Driving Base
Build and attach an Ultrasonic Sensor to your driving base:
[![EV3 Ultrasonic Sensor Driving Base Building Instructions Main Image](/static/lessons/common/ev3-ultrasonic-sensor-driving-base.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-ultrasonic-sensor-driving-base-61ffdfa461aee2470b8ddbeab16e2070.pdf)
## Detect an Object
**Code it:** Create a program that moves the Driving Base and makes it stop ``6`` cm from the Cuboid.
Create a new program:
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.tank(50, 50)
sensors.ultrasonic4.setThreshold(UltrasonicSensorEvent.ObjectDetected, 6)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected);
motors.stopAll()
})
```
* Drag a ``||motors:tank large motors B+C||`` motor block inside the ``||brick:on button||`` block.
* Drag the Ultrasonic Sensor threshold ``||sensors:set ultrasonic 4||`` block and place it below the motor block.
* Drag a ``|sensors:pause until ultrasonic 4||`` block and place it under the threshold block.
* Drag a ``||motors:stop all motors||`` block and place it below the sensor block.
### ~hint
**Hint:** You will have to modify the values of the Ultrasonic Sensor block until the robot reaches the desired position.
### ~
**Download:** Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the center button on the EV3 Brick to run the program.
Click on the **JavaScript** tab. Change and test the number value of the Ultrasonic
Sensor.
```typescript
sensors.ultrasonic4.setThreshold(UltrasonicSensorEvent.ObjectDetected, 10)
```
**Congratulations!**
You are ready to move on to the next steps.
Try a [Design Engineering](/design-engineering), [Coding](/coding), or [Maker](/maker) activity.

View File

@ -1,3 +1,3 @@
{
"appref": "v"
"appref": "v0.1.57"
}

View File

@ -1,54 +1,55 @@
# Coding in MakeCode
This guide is intended for users who are used to the LabView LEGO Minstorms editor.
This guide helps users who are used to work with @boardname@ to get familiar with using blocks in MakeCode.
## Snap the blocks
## Snap together the blocks
Just like LabView, blocks can be dragged from the cabinet and snapped together
Just like with LabView, blocks in the MakeCode editor can be dragged from the cabinet and snapped together
to create a sequence of program instructions.
The program below **starts**, turns on motor A, waits a second and stop motor A.
Take a look a the LabView program below: it **starts**, turns on motor A, waits a second, and finally stops motor A.
![sequence of block](/static/labview/sequencing.png)
The blocks are similar: they snap on the ``||on start||`` block then latch to each other vertically.
The blocks in MakeCode have similar functions and go together in the same way: they snap into the ``||loops:on start||`` block and then connect to each other vertically.
```blocks
motors.largeA.setSpeed(50)
loops.pause(1000)
motors.largeA.run(50)
pause(1000)
motors.largeA.stop()
```
All block programs can be converted to JavaScript and edited from there as well.
Any block program can be converted to JavaScript and you can edit it as lines of code too.
```typescript
motors.largeA.setSpeed(50)
loops.pause(1000)
motors.largeA.run(50)
pause(1000)
motors.largeA.stop()
```
## Download to the EV3
The MakeCode editor provides a simulator to try out the code in your browser. It restarts automatically after you make a code change. Once you are ready to transfer it to the @boardname@, click the ``||Download||`` button and follow the instructions.
Before you actually run your program on the EV3 Brick, you can first try it in the simulator. The MakeCode editor includes a simulator in the browser for you to test your code. You can make changes to your program and check them out it the simulator to make sure your code works the way want. The similator knows when you modify your code and it restarts automatically to run the new code.
Once you're ready to transfer your program to the EV3 Brick, click the ``|Download|`` button and follow the instructions.
## Single motors
The program below controls a large motor on port A in a variety of ways: setting the speed,
setting the speed for a given time, angle or number of rotations.
This program controls a large motor on port A in several different ways. It sets just the speed and then sets speed for: an amount of time, angle of movement, and a number of rotations.
![Single motor blocks](/static/labview/motors.png)
```blocks
motors.largeA.setSpeed(50);
motors.largeA.setSpeed(50, 1000, MoveUnit.MilliSeconds);
motors.largeA.setSpeed(50, 360, MoveUnit.Degrees);
motors.largeA.setSpeed(50, 1, MoveUnit.Rotations);
motors.largeA.run(50);
motors.largeA.run(50, 1000, MoveUnit.MilliSeconds);
motors.largeA.run(50, 360, MoveUnit.Degrees);
motors.largeA.run(50, 1, MoveUnit.Rotations);
motors.largeA.stop();
```
## Steering
The **steering** blocks allow to synchronize two motors at a precise rate. They can also specify the duration, angle or number of rotations.
The **steering** blocks let you to synchronize two motors at a precise rate. They can also specify the duration, angle, or number of rotations for the motors to turn.
![Steering blocks](/static/labview/steer.png)
@ -62,7 +63,7 @@ motors.largeBC.stop();
## Tank
The **tank** blocks control the speed of two motors, typically from a differential drive robot. They can also specify the duration, angle or number of rotations.
The **tank** blocks control the speed of two motors. These are commonly used for a differential drive robot. The blocks can also specify the duration, angle, or number of rotations.
![Tank block](/static/labview/tank.png)
@ -76,18 +77,18 @@ motors.largeBC.stop();
## Coasting and braking
By default, all motors coast when the move command is done. You can change this behavior with the `set brake`` block.
By default, all motors coast when any command used to move finishes. You can keep them from coasting with the ``||motors:set brake||`` block.
![Brake block](/static/labview/brake.png)
```blocks
motors.largeD.setBrake(true);
motors.largeD.setSpeed(50, 1, MoveUnit.Rotations)
motors.largeD.run(50, 1, MoveUnit.Rotations)
```
## Inverting and regulating motors
Sometime you need to invert the direction of a motor. Use the ``set invert`` block.
If you wan to change the direction that a motor turns, use the ``||motors:set inverted||`` block.
![Brake block](/static/labview/invertmotor.png)
@ -97,7 +98,7 @@ motors.largeA.setInverted(true);
By default, the speed of motors is regulated. This means that if your robot goes up a hill,
the regulator will adjust the power to match the desired speed. You can disable this feature
using ``set regulated``.
using ``||motors:set regulated||``.
![Brake block](/static/labview/unregulatedmotor.png)
@ -107,7 +108,7 @@ motors.largeA.setRegulated(false);
## Brick
The brick category contains a number of blocks to display graphics on the brick screen.
The **Brick** category has a number of blocks to display graphics on the brick screen.
![brick image](/static/labview/brickimage.png)
@ -126,21 +127,20 @@ brick.setStatusLight(StatusLight.OrangePulse);
## Waiting (pausing)
It is quite common to wait for a sensor state, such as a touch button pressed.
The ``pause until`` blocks provide a variety of ways to acheive this.
It is quite common to have to wait for a task to finish or for a sensor state to change, such as a touch button pressed. The ``||loops:pause||`` and ``||sensors:pause until||`` blocks provide a way for your program to wait for a period of time.
![pause for time](/static/labview/pausefortime.png)
```blocks
motors.largeD.setSpeed(50)
loops.pause(1000)
motors.largeD.run(50)
pause(1000)
motors.largeD.stop();
```
![pause for touch](/static/labview/pausefortouch.png)
```blocks
motors.largeD.setSpeed(50)
motors.largeD.run(50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeD.stop();
```
@ -148,16 +148,15 @@ motors.largeD.stop();
![pause for distance](/static/labview/pausefordistance.png)
```blocks
motors.largeD.setSpeed(50)
motors.largeD.run(50)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
motors.largeD.stop();
```
You can also use the ``pause until`` block to wait on any boolean expression.
The runtime will evaluate this expression until it becomes true.
You can also use the ``||loops:pause until||`` block to wait on any [boolean](/types/boolean) expression. As your program runs, it waits until the condition (expression) inside becomes true.
```blocks
motors.largeD.setSpeed(50)
motors.largeD.run(50)
pauseUntil(() => sensors.touch1.isPressed())
motors.largeD.stop()
```
@ -167,9 +166,9 @@ motors.largeD.stop()
![Single loop](/static/labview/loopinfinite.png)
```blocks
loops.forever(() => {
motors.largeD.setSpeed(50, 1, MoveUnit.Rotations);
motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations);
forever(() => {
motors.largeD.run(50, 1, MoveUnit.Rotations);
motors.largeD.run(-50, 1, MoveUnit.Rotations);
})
```
@ -177,13 +176,13 @@ loops.forever(() => {
```blocks
for(let i = 0; i < 10; i++) {
motors.largeD.setSpeed(50, 1, MoveUnit.Rotations);
motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations);
motors.largeD.run(50, 1, MoveUnit.Rotations);
motors.largeD.run(-50, 1, MoveUnit.Rotations);
}
let k = 0;
while(k < 10) {
motors.largeD.setSpeed(50, 1, MoveUnit.Rotations);
motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations);
motors.largeD.run(50, 1, MoveUnit.Rotations);
motors.largeD.run(-50, 1, MoveUnit.Rotations);
k++;
}
```
@ -194,43 +193,41 @@ while(k < 10) {
```blocks
let light = 0;
loops.forever(function () {
forever(function () {
light = sensors.color3.light(LightIntensityMode.Reflected);
motors.largeD.setSpeed(light)
motors.largeD.run(light)
})
```
## Concurrent loops
You can spin up multiple ``forever`` loops that will run at the same time.
Only one code is running at the time, but each loop iteration will interleave.
You can start up multiple ``||loops:forever||`` loops that will run at the same time. Actually, only the code in just one of the loops is really running at any exact moment in time. Each loop, though, gets a turn to run all of its code and this makes them run [_concurrently_](https://en.wikipedia.org/wiki/Concurrent_computing).
![Brake block](/static/labview/multipleloops.png)
![Multiple loops running at the same time](/static/labview/multipleloops.png)
```blocks
loops.forever(() => {
motors.largeD.setSpeed(50, 1, MoveUnit.Rotations);
motors.largeD.setSpeed(-50, 1, MoveUnit.Rotations);
forever(() => {
motors.largeD.run(50, 1, MoveUnit.Rotations);
motors.largeD.run(-50, 1, MoveUnit.Rotations);
})
loops.forever(() => {
forever(() => {
brick.showImage(images.eyesMiddleRight)
loops.pause(1000)
pause(1000)
brick.showImage(images.eyesMiddleLeft)
loops.pause(1000)
pause(1000)
})
```
## Conditional
The ``if`` block allow to run different code based on a boolean condition.
This is similar to the switch block.
The ``||logic:if||`` block allows you to run different code depending on whether some condition ([boolean](/types/boolean) expression) is `true` or `false`. Also, this is similar to the ``||loops:switch||`` block.
![Brake block](/static/labview/ife.png)
```blocks
loops.forever(function() {
forever(function() {
if(sensors.touch1.isPressed()) {
motors.largeD.setSpeed(50)
motors.largeD.run(50)
} else {
motors.largeD.stop()
}
@ -239,13 +236,13 @@ loops.forever(function() {
## Random
The ``random range`` blocks returns number between two bounds.
The ``||math:pick random||`` block returns a random number selected from a range of numbers.
![Brake block](/static/labview/random.png)
```blocks
loops.forever(function () {
forever(function () {
motors.largeBC.steer(Math.randomRange(-5, 5), 50)
loops.pause(100)
pause(100)
})
```

View File

@ -1,6 +1,6 @@
# Lessons
Learning activities for LEGO Mindstorms with MakeCode.
Learning activities for @boardname@ with MakeCode.
## Motors and motion

View File

@ -60,18 +60,18 @@ while (true) {
### Step 3
Place a ``||sensors:pause for color||`` from ``||sensors:Sensors||`` inside the ``||loops:while||`` loop block. Change the color to red.
Place a ``||sensors:pause until color detected||`` from ``||sensors:Sensors||`` inside the ``||loops:while||`` loop block. Change the color to red.
```blocks
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
}
```
### Step 4
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause for color||`` block.
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause until color detected||`` block.
Study the program...what do you think the program will do?
@ -80,8 +80,8 @@ Study the program...what do you think the program will do?
```blocks
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.stopAllMotors()
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
}
```
@ -128,27 +128,27 @@ while (true) {
### Step 5
Place a ``||sensors:pause for color||`` block from ``||sensors:Sensors||`` inside the ``||loops:while||`` loop block. Change the color to red.
Place a ``||sensors:pause until color detected||`` block from ``||sensors:Sensors||`` inside the ``||loops:while||`` loop block. Change the color to red.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
}
}
```
### Step 6
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause for color||`` block.
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause until color detected||`` block.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.stopAllMotors()
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
}
}
```
@ -161,8 +161,8 @@ Place a ``||loops:while||`` loop block under the second ``||loops:while||`` loop
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.stopAllMotors()
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
}
while (true) {
@ -172,7 +172,7 @@ while (true) {
### Step 8
Place a ``||sensors:pause for color||`` block inside the new ``||loops:while||`` loop block. Change the color to red.
Place a ``||sensors:pause unril color detected||`` block inside the new ``||loops:while||`` loop block. Change the color to red.
What do you think the program will do?
@ -182,11 +182,11 @@ What do you think the program will do?
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.stopAllMotors()
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
}
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
}
}
```
@ -208,18 +208,19 @@ Think about what you have learned, then document it. Describe your pseudocode fo
```blocks
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Yellow)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Yellow)
music.playSoundEffect(sounds.systemGeneralAlert)
}
while (true) {
while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.setSpeed(10)
motors.largeC.setSpeed(-10)
while (true) {
sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Bright)
motors.largeB.run(10)
motors.largeC.run(-10)
}
while (true) {
sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeA.setSpeed(-10)
motors.largeA.setSpeed(10)
sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Bright)
motors.largeA.run(-10)
motors.largeA.run(10)
}
}
```
@ -234,14 +235,15 @@ You will need to constantly debug your program in order to make your robot trave
```blocks
while (true) {
while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.setSpeed(10)
motors.largeC.setSpeed(-10)
while (true) {
sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Bright)
motors.largeB.run(10)
motors.largeC.run(-10)
}
while (true) {
sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.setSpeed(-10)
motors.largeC.setSpeed(10)
sensors.color3.pauseUntilLightDetected(LightIntensityMode.Reflected, Light.Bright)
motors.largeB.run(-10)
motors.largeC.run(10)
}
}
```

View File

@ -10,7 +10,7 @@ Your robot will:
* Use at least one motor
* Use NO wheels for locomotion
![LECG Mindstorms brick with parts](/static/lessons/make-it-move/locomotion-no-wheels.jpg)
![@boardname@ with parts](/static/lessons/make-it-move/locomotion-no-wheels.jpg)
## Construct @unplugged
@ -25,7 +25,7 @@ The legs in the Walker Bot are designed to show how to change the rotary motion
Start by reading [these](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/ev3-dep/building%20instructions/walker-bot-bi-180fc24f9298e1dd6201099627d43903.pdf) instructions first.
![LEGO Mindstorms Walker Bot](/static/lessons/make-it-move/walker-bot.jpg)
![@boardname@ Walker Bot](/static/lessons/make-it-move/walker-bot.jpg)
## Program 1 @fullscreen
@ -37,7 +37,7 @@ Place a ``||motors:tank large B+C||`` block from ``||motors:Motors||`` under ``|
Change the speed to `-60%` (for motor B) and `+60%` (for motor C).
Change the rotations to `9`.
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 brick. The motors are set for the reverse direction because they are mounted upside down in this model.
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 Brick. The motors are set for the reverse direction because they are mounted upside down in this model.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
@ -47,11 +47,11 @@ motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
Place a ``||motors:stop all motors||`` block under ``||motors:tank large B+C||``.
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 brick then stop.
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 Brick then stop.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
motors.stopAllMotors()
motors.stopAll()
```
## Program 3 @fullscreen
@ -59,11 +59,11 @@ motors.stopAllMotors()
Place a ``||brick:show string||`` block under ``||motors:stop all motors||``.
Change the `"Hello World"` text to `"30 cm"`.
The ``||motors:tank large B+C||`` will run for `9` rotations when the **center** button is pressed on the EV3 brick then stop and display "30 cm" on the EV3 Bricks screen.
The ``||motors:tank large B+C||`` will run for `9` rotations when the **center** button is pressed on the EV3 Brick then stop and display "30 cm" on the EV3 Bricks screen.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
motors.stopAllMotors()
motors.stopAll()
brick.showString("30 cm", 1)
```

View File

@ -10,7 +10,7 @@ Your robot will:
* Use at least one motor
* Use NO wheels for locomotion
![LECG Mindstorms brick with parts](/static/lessons/make-it-move/locomotion-no-wheels.jpg)
![@boardname@ with parts](/static/lessons/make-it-move/locomotion-no-wheels.jpg)
## Construct
@ -24,7 +24,7 @@ The legs in the Walker Bot are designed to show how to change the rotary motion
Start by reading [these](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/ev3-dep/building%20instructions/walker-bot-bi-180fc24f9298e1dd6201099627d43903.pdf) instructions first.
![LEGO Mindstorms Walker Bot](/static/lessons/make-it-move/walker-bot.jpg)
![@boardname@ Walker Bot](/static/lessons/make-it-move/walker-bot.jpg)
## Program
@ -38,7 +38,7 @@ Place a ``||motors:tank large B+C||`` block from ``||motors:Motors||`` under ``|
Change the speed to `-60%` (for motor B) and `+60%` (for motor C).
Change the rotations to `9`.
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 brick. The motors are set for the reverse direction because they are mounted upside down in this model.
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 Brick. The motors are set for the reverse direction because they are mounted upside down in this model.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
@ -48,7 +48,7 @@ motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
Place a ``||motors:stop all motors||`` block under ``||motors:tank large B+C||``.
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 brick then stop.
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 Brick then stop.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
@ -60,7 +60,7 @@ motors.largeBC.stop()
Place a ``||brick:show string||`` block under ``||motors:stop all motors||``.
Change the `"Hello World"` text to `"30 cm"`.
The ``||motors:tank large B+C||`` will run for `9` rotations when the **center** button is pressed on the EV3 brick then stop and display "30 cm" on the EV3 Bricks screen.
The ``||motors:tank large B+C||`` will run for `9` rotations when the **center** button is pressed on the EV3 Brick then stop and display "30 cm" on the EV3 Bricks screen.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)

View File

@ -1,47 +1,24 @@
# Maker Activites
These six activities require the LEGO® MINDSTORMS® Education EV3 Core Set (45544). Supporting materials for teachers and middle school students are provided, offering everything teachers and students need to explore their inner makers as they follow the design process to solve open-ended, themed challenges...
* [Download Curriculum Materials](https://education.lego.com/en-us/downloads/mindstorms-ev3)
## Activites
```codecard
[
{
"name": "Sound Machine",
"description": "Create instruments with your EV3 Brick!",
"name": "Make A Sound Machine",
"description": "Make a Sound Machine that can play a rhythm, music or just noise!",
"url":"/maker/sound-machine",
"cardType": "example",
"imageUrl": "/static/maker/sound-machine.png"
"imageUrl": "/static/lessons/make-a-sound-machine.png",
"cardType": "side"
},
{
"name": "Sound Of Color",
"description": "Play different sounds based on the color",
"url":"/maker/sound-of-color",
"cardType": "example",
"imageUrl": "/static/maker/sound-of-color.png"
},
{
"name": "Security Gadget",
"description": "Raise the alarm when your brick is lifted!",
"name": "Make A Security Gadget",
"description": "Invent a Security Gadget that will protect your belongings by warning you!",
"url":"/maker/security-gadget",
"cardType": "example",
"imageUrl": "/static/maker/security-gadget.png"
},
{
"name": "Intruder Detector",
"description": "Raise the alarm when an intruder sneaks in",
"url":"/maker/intruder-detector",
"cardType": "example",
"imageUrl": "/static/maker/intruder-detector.png"
},
{
"name": "Puppet",
"description": "Build an automated puppet",
"url":"/maker/puppet",
"cardType": "example",
"imageUrl": "/static/maker/puppet.png"
"imageUrl": "/static/lessons/make-a-security-device.png",
"cardType": "side"
}
]
```

View File

@ -1,4 +1,4 @@
# Intruder Detector
# Movement Detector
This program will activate an alarm when an object moves in front of the Ultrasonic Sensor.

View File

@ -3,13 +3,13 @@
Use this program with the Programmable Brick and Large Motor.
```blocks
loops.forever(function () {
motors.largeA.setSpeed(30)
loops.pause(100)
forever(function () {
motors.largeA.run(30)
pause(100)
motors.largeA.stop()
music.playSoundEffectUntilDone(sounds.animalsCatPurr)
motors.largeA.setSpeed(-30)
loops.pause(100)
motors.largeA.run(-30)
pause(100)
motors.largeA.stop()
})
```

View File

@ -1,9 +1,141 @@
# Security Gadget
This program will activate an alarm when an object is lifted from the Touch Sensor.
# Make a Security Gadget
Invent a Security Gadget that will protect your belongings by warning you!
![Maker Make a Security Gadget Main Image](/static/lessons/make-a-security-gadget/lego-maker-security-detect.jpg)
## Connect
Over time, people have come up with many different ways to help protect their personal belongings from theft. These inventions include simple alarm systems and even traps!
![Make a Security Gadget 3 Stock Footage Images](/static/lessons/make-a-security-gadget/three-stock.jpg)
Look at the photos and think about:
* What do you see?
* Can you see any new design opportunities?
* What problems can you see?
* How could you make use of the LEGO bricks, the EV3 Programmable Brick, motors, and sensors?
### Things Youll Need
* [@boardname@ Core Set](https://education.lego.com/enus/products/legomindstormseducationev3coreset/5003400)
Additional materials to add to your Security Gadget:
* String
* Arts and crafts materials such as:
>* Cardboard
>* Construction paper
>* Pipe cleaners
>* Plastic or paper cups
>* Recycled materials
>* Rubber bands
>* Wire
### Prior Knowledge
This activity uses sensor inputs. You may want to try the [Use](/getting-started/use) or [Object Detection](/coding/object-detection) activity before this one. Or, you can start out with this activity and tinker with coding sensor inputs on your own.
## Contemplate
Follow the steps of the _Maker Design Process_ for this lesson:
| | |
|-|-|
| ![Paper sheet icon](/static/maker/design-process-icons/define-problem.png) | **Define the Problem** |
| ![Lightbulb icon](/static/maker/design-process-icons/brainstorming.png) | **Brainstorming** |
| ![Checkmark icon](/static/maker/design-process-icons/define-criteria.png) | **Define the Design Criteria** |
| ![Connector icon](/static/maker/design-process-icons/go-make.png) | **Go Make** |
| ![Redo icon](/static/maker/design-process-icons/review-revise.png) | **Review and Revise Your Solution** |
| ![Speaker icon](/static/maker/design-process-icons/communicate.png) | **Communicate Your Solution** |
### Defining the Problem
1. What problems did you imagine?
2. Pick one problem and explain it to a partner.
### Brainstorm
Now that you have defined a problem, start to generate ideas for solving it.
### ~hint
Some things to do while brainstorming:
* Use the bricks from the LEGO set to help you brainstorm or sketch your ideas on paper.
* The goal of brainstorming is to explore as many solutions as possible. You can use the tinkering examples in the Sample Solutions section below as inspiration for getting started.
* Share your ideas and get some feedback. It may lead to more ideas!
### ~
### Define the Design Criteria
1. You should have generated a number of ideas. Now select the best one to make.
2. Write out two or three specific design criteria your design must meet.
### Go Make
It is time to start making!
* Use the components from the @boardname@ Core Set and additional materials to make your chosen solution.
* Test and analyze your design as you go and record any improvements that you make.
### Review and Revise Your Solution
* Have you managed to solve the problem that you defined?
* Look back at your design criteria. How well does your solution work?
* How can you improve your design?
### Communicate Your Solution
Now that you have finished you can:
* Make a sketch or take a photo or video of your model.
* Label the three most important parts and explain how they work.
* Share your work with others.
## Continue
### Phone Protector - Sample Solution
This example program combined with the small model will sound an alarm if someone picks it up. The program activates an alarm when an object is lifted from the Touch Sensor.
![Security Gadget Tinkering Example #1 Phone Stand](/static/lessons/make-a-security-gadget/lego-maker-security-gadget.jpg)
#### Programming
1. Drag a ``||sensors:pause until touch||`` block and place it inside the ``||loops:forever||`` loop.
2. Drag a ``||music:play sound effect||`` block and place it below the ``||sensors:pause until||`` block.
3. Change the sound effect to ``mechanical horn1``.
```blocks
sensors.touch1.onEvent(ButtonEvent.Released, function () {
music.playSoundEffectUntilDone(sounds.informationActivate);
forever(function () {
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
music.playSoundEffect(sounds.mechanicalHorn1)
})
```
```
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
### Object Detection - Sample Solution
This example program combined with the small model will sound an alarm if someone (or something) crosses its path! The program activates an alarm when an object moves in front of the Ultrasonic Sensor.
![Security Gadget Tinkering Example #1 Mouse detector](/static/lessons/make-a-security-gadget/lego-maker-security-detect.jpg)
#### Programming
1. Drag a ``||sensors:pause until ultrasonic||`` block and place it inside the ``||loops:forever||`` loop.
2. Drag a ``||music:play sound effect||`` block and place it below the ``||sensors:pause until||`` block.
3. Change the sound effect to ``mechanical horn1``.
```blocks
forever(function () {
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected)
music.playSoundEffect(sounds.mechanicalHorn1)
})
```
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.

View File

@ -1,12 +1,165 @@
# Sound Machine
# Make a Sound Machine
Make a Sound Machine that can play a rhythm, music or just noise!
![Maker Make a Sound Machine Main Image](/static/lessons/make-a-sound-machine/lego-maker-sound-machine-1.jpg)
## Connect
Music is made up of a combination of sounds, notes and rhythm. A rhythm is a regular movement or repeated pattern of movements that can be used in many different ways. In mechanical machines, a rhythm can help keep a machine running smoothly. It can also be used to generate different sounds in music.
![Sound Machine 3 Stock Footage Images](/static/lessons/make-a-sound-machine/three-stock.jpg)
Look at the photos and think about:
* What do you see?
* Can you see any new design opportunities?
* What problems can you see?
* How could you make use of the LEGO bricks, the EV3 Programmable Brick, motors, and sensors?
### Things Youll Need
* [@boardname@ Core Set](https://education.lego.com/enus/products/legomindstormseducationev3coreset/5003400)
Additional materials to add to your Sound Machine:
* Small musical instruments, such as chimes, bells, and small drums
* Arts and crafts materials such as:
>* Cardboard
>* Construction paper
>* Pipe cleaners
>* Plastic or paper cups
>* Recycled materials
>* Rubber bands
>* Wire
### Prior Knowledge
This activity uses motor rotations and sensor inputs. You may want to try the [Use](/getting-started/use) or [Object Detection](/coding/object-detection) activity before this one. Or, you can start out with this activity and tinker with coding motor and sensor inputs on your own.
## Contemplate
Follow the steps of the _Maker Design Process_ for this lesson:
| | |
|-|-|
| ![Paper sheet icon](/static/maker/design-process-icons/define-problem.png) | **Define the Problem** |
| ![Lightbulb icon](/static/maker/design-process-icons/brainstorming.png) | **Brainstorming** |
| ![Checkmark icon](/static/maker/design-process-icons/define-criteria.png) | **Define the Design Criteria** |
| ![Connector icon](/static/maker/design-process-icons/go-make.png) | **Go Make** |
| ![Redo icon](/static/maker/design-process-icons/review-revise.png) | **Review and Revise Your Solution** |
| ![Speaker icon](/static/maker/design-process-icons/communicate.png) | **Communicate Your Solution** |
### Defining the Problem
1. What problems did you imagine?
2. Pick one problem and explain it to a partner.
### Brainstorm
Now that you have defined a problem, start to generate ideas for solving it.
### ~hint
Some things to do while brainstorming:
* Use the bricks from the LEGO set to help you brainstorm or sketch your ideas on paper.
* The goal of brainstorming is to explore as many solutions as possible. You can use the tinkering examples in the Sample Solutions section below as inspiration for getting started.
* Share your ideas and get some feedback. It may lead to more ideas!
### ~
### Define the Design Criteria
* You should have generated a number of ideas. Now select the best one to make.
* Write out two or three specific design criteria your design must meet.
### Go Make
It is time to start making!
* Use the components from the @boardname@ Core Set and additional materials to make your chosen solution.
* Test and analyze your design as you go and record any improvements that you make.
### Review and Revise Your Solution
* Have you managed to solve the problem that you defined?
* Look back at your design criteria. How well does your solution work?
* How can you improve your design?
### Communicate Your Solution
Now that you have finished you can:
* Make a sketch or take a photo or video of your model.
* Label the three most important parts and explain how they work.
* Share your work with others.
## Continue
### Rhythm Maker - Sample Solution
This example program combined with the small model will make a beat and rhythm on any surface when the program is run.
![Sound Machine Tinkering Example](/static/lessons/make-a-sound-machine/lego-maker-sound-machine.jpg)
#### Programming
1. Drag a run ``||motors:large motor A||`` block inside the ``||loops:forever||`` loop.
2. Press the **(+)**.
3. Change the rotations to `2`.
4. Drag a ``||loops:pause||`` block and place it under the motor block.
5. Change the duration to ``200`` ms.
6. Drag a ``||run large motor A||`` block inside the ``||loops:forever||`` loop.
7. Press the **(+)**.
8. Change the power to `100`.
9. Change the rotations to `1`.
```blocks
loops.forever(function () {
motors.largeA.setSpeed(50)
loops.pause(200)
motors.largeA.setSpeed(100)
loops.pause(200)
forever(function () {
motors.largeA.run(50, 2, MoveUnit.Rotations)
pause(200)
motors.largeA.run(100, 1, MoveUnit.Rotations)
})
```
```
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.
### Color Sensor Sounds - Sample Solution
You can also tinker with the use of sensors.
![Sound Machine Color Sensor](/static/lessons/make-a-sound-machine/lego-maker-sound-machine-color-sensor.jpg)
#### Programming
1. Drag an ``||logic:if else||`` Logic block and place it inside the ``||loops:forever||`` loop.
2. Drag a ``||sensors:pause color sensor||`` block and place it inside the ``||logic:if true then||`` block.
3. Change the color to ``blue``.
4. Drag a ``||music:play tone||`` block and place under the sensor block.
5. Change the tone to ``Middle G`` (392 Hz).
6. Drag a ``||sensors:pause color sensor||`` block and place it inside the ``||logic:else||`` block.
7. Change the color to ``red``.
8. Drag a ``||music:play tone||`` block and place under the new sensor block.
9. Change the tone to ``High C`` (523 Hz).
10. Press the **(+)**.
11. Drag a ``||sensors:pause color sensor||`` block and place it inside the ``||logic:else if||`` block.
12. Change the color to ``green``.
13. Drag a ``||music:play tone||`` block and place under the new sensor block.
14. Change the tone to ``High D`` (587 Hz).
```blocks
forever(function () {
if (true) {
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Blue)
music.playTone(392, music.beat(BeatFraction.Whole))
} else if (false) {
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
music.playTone(523, music.beat(BeatFraction.Half))
} else {
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
music.playTone(587, music.beat(BeatFraction.Half))
}
})
```
Click **Download** and follow the instructions to get your code onto your EV3 Brick. Press the ``center`` button on the EV3 Brick to run the program.

View File

@ -4,6 +4,6 @@ Here are some cool projects that you can build with your @boardname@!
## Basic
Basic projects to build with your @boardname@.
Basic projects to build with your EV3 Brick.
Coming soon.

View File

@ -1,13 +1,24 @@
# Reference
```namespaces
music.playSoundEffect(sounds.animalsCatPurr);
sensors.color(null);
motors.stopAll();
brick.showMood(moods.sleeping);
motors.stopAllMotors()
```
## Advanced
```namespaces
console.log("");
control.runInParallel(function(){});
```
## See Also
[brick](/reference/brick),
[sensors](/reference/sensors),
[motors](/reference/motors),
[touch sensor](/reference/sensors/touch-sensor),
[color sensor](/reference/sensors/color-sensor)
[music](/reference/music),
[control](/reference/control),
[console](/reference/console)

View File

@ -9,6 +9,7 @@ brick.showString("Hello world!", 1);
brick.showNumber(0, 1);
brick.showValue("item", 0, 1);
brick.clearScreen();
brick.showPorts();
```
## Buttons
@ -19,8 +20,8 @@ brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
});
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
brick.buttonEnter.isPressed()
brick.buttonEnter.wasPressed()
brick.setStatusLight(StatusLight.Red);
brick.buttonEnter.wasPressed()
```
## Other

View File

@ -16,7 +16,7 @@ Show the battery level percentage on the screen. Also, show a green light if the
```blocks
let battery = 0;
loops.forever(function() {
forever(function() {
brick.showString("Battery level:", 1)
brick.showNumber(battery, 2)
battery = brick.batteryLevel();
@ -28,6 +28,6 @@ loops.forever(function() {
} else {
brick.setStatusLight(StatusLight.RedPulse)
}
loops.pause(30000)
pause(30000)
})
```

View File

@ -32,7 +32,7 @@ Set the brick light to green when the `down` is pressed. When the button is not
```blocks
let isRed = false;
loops.forever(function() {
forever(function() {
if (brick.buttonLeft.isPressed()) {
brick.setStatusLight(StatusLight.Green);
isRed = false;

View File

@ -14,7 +14,7 @@ The fact that a button was pressed earlier is remembered. Once **was pressed** i
Your @boardname@ has touch sensors that work like buttons. Instead of saying `enter` or `left` as the source button, use a touch sensor block with a sensor name like `touch 1`.
```block
```typescript
if (sensors.touch1.wasPressed()) {
console.log("Hey, I was pressed.");
}
@ -32,7 +32,7 @@ Read about [touch sensors](/reference/sensors/touch-sensor) and using them as to
Set the brick light to green if the `right` button was pressed before the `left` button. If not, the brick light is turned off when the `left` button is pressed.
```blocks
```typescript
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() {
if (brick.buttonRight.wasPressed()) {
brick.setStatusLight(StatusLight.Green)
@ -45,6 +45,5 @@ brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() {
## See also
[is pressed](/reference/brick/button/is-pressed),
[on event](/reference/brick/button/on-event)
[on event](/reference/brick/button/on-event),
[Touch sensors](/reference/sensors/touch-sensor)

View File

@ -16,7 +16,7 @@ brick.showString("self-destruct in:", 2);
brick.showString("seconds", 5);
for (let i = 0; i < 10; i++) {
brick.showNumber(10 - i, 4);
loops.pause(1000);
pause(1000);
}
brick.clearScreen();
```

View File

@ -24,14 +24,14 @@ brick.setStatusLight(StatusLight.Red);
Repeatedly show a different color pattern for the brick light.
```blocks
loops.forever(function () {
forever(function () {
brick.setStatusLight(StatusLight.Orange)
loops.pause(1000)
pause(1000)
brick.setStatusLight(StatusLight.GreenFlash)
loops.pause(2000)
pause(2000)
brick.setStatusLight(StatusLight.RedPulse)
loops.pause(2000)
pause(2000)
brick.setStatusLight(StatusLight.Off)
loops.pause(500)
pause(500)
})
```

View File

@ -0,0 +1,24 @@
# show Ports
Show the status of everything connected to the ports.
```sig
brick.showPorts()
```
You can find out what's connected to the ports on the brick and show its status. The status information from each sensor or motor connected is displayed on the screen.
## Example
Show the status of the ports on the brick when the ``enter`` button is pressed.
```blocks
brick.showString("Press ENTER for port status", 1)
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
brick.showPorts()
})
```
## See also
[show string](/reference/brick/show-string), [show value](/reference/brick/show-value)

15
docs/reference/console.md Normal file
View File

@ -0,0 +1,15 @@
# Console
Output text and data values to the console.
```cards
console.log("");
console.logValue("x", 0);
console.sendToScreen();
```
## See also
[log](/reference/console/log),
[log value](/reference/console/log-value),
[send to screen](/reference/console/send-to-screen)

View File

@ -0,0 +1,26 @@
# send To Screen
Direct the console output to go to the @boardname@ screen.
```sig
console.sendToScreen();
```
A "console" is a place for a user to see special messages from a device. It could be something connected to a serial port, a display that shows text, or even a text file. A console is typically used as a place to send information that is added to a message _log_ (a record of messages that are sent from a device). Your program can send log messages using the [console](/reference/console) functions. The MakeCode editor has a console view that lets you see the console output when your program runs in the simulator.
On the EV3 Brick, the screen can serve as a console too and you can make your console output go there. Before using the console log functions, set the screen as the console output location.
## Example
Direct the console output to go to the screen. Show 20 values on the screen. Use the up and down buttons to scroll through the values.
```blocks
console.sendToScreen()
for (let index = 0; index <= 20; index++) {
console.logValue("index", index)
}
```
## See also
[log](reference/console/log), [log value](/reference/console/log-value)

33
docs/reference/control.md Normal file
View File

@ -0,0 +1,33 @@
# Control
Program controls and events.
```cards
control.millis();
control.runInParallel(() => {
});
control.reset();
control.waitMicros(4);
control.deviceSerialNumber();
```
## Timer
```cards
control.timer1.reset()
control.timer1.pauseUntil(5)
control.timer1.millis()
control.timer1.seconds()
```
## Advanced #advanced
```cards
control.raiseEvent(0, 0);
control.onEvent(0, 0, () => {
});
control.assert(false, 0);
control.panic(0);
```

View File

@ -0,0 +1,12 @@
# @extends
## Example #example
Stop the program if the gyro dectects an angle greater than 45 degrees.
```blocks
forever(function () {
control.assert(sensors.gyro2.angle() > 45, 15)
pause(300)
})
```

View File

@ -0,0 +1,9 @@
# @extends
## Example #example
Log the device serial number to the console.
```blocks
console.logValue("serialnumber", control.deviceSerialNumber());
```

View File

@ -0,0 +1,25 @@
# @extends
# Example #example
Register two events coming from source `22`. Make the brick status light up when
the events of `0` and `1` are _raised_.
```blocks
const statusLighter = 22;
control.runInParallel(() => {
for (let i = 0; i < 2; i++) {
pause(1000);
control.raiseEvent(statusLighter, i);
}
})
control.onEvent(statusLighter, 0, () => {
brick.setStatusLight(StatusLight.OrangePulse)
})
control.onEvent(statusLighter, 1, () => {
brick.setStatusLight(StatusLight.GreenPulse)
})
```

View File

@ -0,0 +1,13 @@
# @extends
## Example #example
Send a 'code red' error that you created to the error display if the brick crashes into a wall.
```blocks
let codeRed = 1
let codeBlue = 2
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
control.panic(codeRed)
})
```

View File

@ -0,0 +1,25 @@
# @extends
# Example #example
Register two events coming from source `22`. Make the brick status light up when
the events of `0` and `1` are _raised_.
```blocks
const statusLighter = 22;
control.runInParallel(() => {
for (let i = 0; i < 2; i++) {
pause(1000);
control.raiseEvent(statusLighter, i);
}
})
control.onEvent(statusLighter, 0, () => {
brick.setStatusLight(StatusLight.OrangePulse)
})
control.onEvent(statusLighter, 1, () => {
brick.setStatusLight(StatusLight.GreenPulse)
})
```

View File

@ -0,0 +1,61 @@
# @extends
## Separate tasks #tasks
As an example, you could have a small task that checks the battery level and gives a warning when it drops below 15 percent. This is placed inside a ``||control:run in parallel||`` block:
```block
let powerCheck = false;
control.runInParallel(() => {
while (!powerCheck) {
if (brick.batteryLevel() <= 15) {
brick.setStatusLight(StatusLight.RedFlash)
powerCheck = true;
} else {
pause(5000);
}
}
})
```
The code the main program just drives the brick in a constant pattern until the battery check in the parallel task says that the battery level is too low.
```block
let powerCheck = false;
while (!powerCheck) {
motors.largeBC.tank(50, 50, 5, MoveUnit.Seconds)
motors.largeBC.steer(5, 50, 6, MoveUnit.Rotations)
}
motors.stopAll()
```
## #example
Tank the brick in a pattern until the battery warning variable is set. Have a separate task check the battery level and set a warning variable when the level is below `5` percent.
```blocks
let powerCheck = false;
control.runInParallel(() => {
while (!powerCheck) {
if (brick.batteryLevel() < 5) {
powerCheck = true;
} else {
pause(5000);
}
}
})
while (!powerCheck) {
motors.largeBC.tank(20, 20, 5, MoveUnit.Seconds)
motors.largeBC.steer(15, 20, 6, MoveUnit.Rotations)
motors.largeBC.tank(40, 40, 5, MoveUnit.Seconds)
motors.largeBC.steer(-10, 20, 3, MoveUnit.Rotations)
}
motors.stopAll()
```
## See also #seealso
[forever](/reference/loops/forever)

View File

@ -0,0 +1,8 @@
# Timer
```cards
control.timer1.reset()
control.timer1.pauseUntil(5)
control.timer1.millis()
control.timer1.seconds()
```

View File

@ -0,0 +1,25 @@
# millis
Get the amount of time counted by the timer in milliseconds.
The timer count begins from `0` when you program starts or is [reset](/reference/control/timer/reset).
## Returns
* a [number](/types/number) that is the amount of time elapsed, in milliseconds, since the timer was started or reset.
## Example
Find out how many milliseconds go by between presses of the `down` button on the brick.
```blocks
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
brick.showValue("DownButtonTime", control.timer1.millis(), 1)
control.timer1.reset()
})
```
## See also
[seconds](/reference/control/timer/seconds), [reset](/reference/control/timer/reset)

View File

@ -0,0 +1,32 @@
# pauseUntil
Pause until the timer counts up to a number of milliseconds.
```sig
control.timer1.pauseUntil(0)
```
When code in a block comes to a **pauseUntil**, it will wait until the timer count reaches the number of milliseconds you say. Code in blocks like **forever** and **runInParallel** will keep running while the current code is paused.
The time number you give is the number of milliseconds past the running timer count. If the timer is currently at `25000` milliseconds and you want to pause for `10` seconds, then use a pause time of `35000`. If you want your pause time number to match the actual wait time, then [reset](/reference/control/timer/reset) the timer first.
## Parameters
* **ms**: the [number](/types/number) of milliseconds that you want the timer to count up to. For seconds, convert to milliseconds: 100 milliseconds = 1/10 second and 1000 milliseconds = 1 second.
## Example
Pause between messages on the screen by `5` seconds.
```blocks
brick.clearScreen()
brick.showString("Testing my pause...", 1)
let startTime = control.timer1.millis()
brick.showValue("StartTime", startTime, 3)
control.timer1.pauseUntil(startTime + 5000)
brick.showValue("EndTime", control.timer1.millis() - startTime, 4)
```
## See also
[millis](/reference/control/timer/millis), [reset](/reference/control/timer/reset)

View File

@ -0,0 +1,49 @@
# reset
Reset the elapsed time of the timer back to `0`.
```sig
control.timer1.reset()
```
A timer starts counting from `0` when your program starts. It's time value always gets larger as your program runs. Maybe you want to meausure how long some task takes to finish or you want to do some action only for a little while. A timer can keep track of the time it takes to do it.
Resetting the timer sets the time value to `0` so the next time you check the time it's exactly the amount of time that has _elapsed_. Otherwise, you need to remember a start time value and then subtract it from the current time.
## Examples
### Press time
Find out how much time goes by between presses of the `enter` button on the brick.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
brick.showValue("PressTime", control.timer1.seconds(), 1)
control.timer1.reset()
})
```
### Difference timer
Use a difference timer and compare it to a timer that resets. Use the ``left`` button to start timing and the ``right`` button to stop.
```blocks
let startTime = 0
let timing = false
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
brick.clearScreen()
brick.showString("Starting timers...", 1)
startTime = control.timer1.seconds()
control.timer2.reset()
timing = true
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
if (timing) {
brick.clearScreen()
brick.showString("Timer results...", 1)
brick.showValue("timer 1", control.timer1.seconds() - startTime, 3)
brick.showValue("timer 2", control.timer2.seconds(), 4)
timing = false;
}
})
```

View File

@ -0,0 +1,25 @@
# seconds
Get the amount of time counted by the timer in seconds.
The timer count begins from `0` when you program starts or is [reset](/reference/control/timer/reset). The number of seconds returned also includes milliseconds if there is a fractional part of a second too.
## Returns
* a [number](/types/number) that is the amount of time elapsed, in seconds, since the timer was started or reset.
## Example
Find out how many seconds go by between presses of the `down` button on the brick.
```blocks
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
brick.showValue("DownButtonTime", control.timer1.seconds(), 1)
control.timer1.reset()
})
```
## See also
[millis](/reference/control/timer/millis), [reset](/reference/control/timer/reset)

View File

@ -0,0 +1,17 @@
# @extends
## Example #example
Use the a wait and the timer to generate a crazy number.
```blocks
let crazy = 0
for (let i = 0; i < 100; i++) {
control.waitMicros(100)
crazy = control.millis()
crazy += control.deviceSerialNumber()
if (crazy != 0) {
crazy = crazy / 1000000
}
}
```

View File

@ -3,7 +3,7 @@
## Motion
```cards
motors.largeA.setSpeed(50)
motors.largeA.run(50)
motors.largeAB.tank(50, 50)
motors.largeAB.steer(0, 50)
motors.largeA.pauseUntilReady()
@ -12,13 +12,12 @@ motors.largeA.setInverted(true)
motors.largeA.setRegulated(false)
motors.largeA.stop()
motors.largeA.reset()
motors.stopAllMotors()
motors.stopAll()
```
## Counters
```cards
motors.largeA.speed()
motors.largeA.angle()
motors.largeA.tacho()
motors.largeA.clearCounts()
```

View File

@ -6,11 +6,11 @@ Get the current angle of the motor's rotation in degrees.
motors.largeA.angle()
```
When a motor is started for the first time, or after a reset, it's angle of rotation starts at `0` degrees. A complete rotation (a turn in a full circle) is `360` degrees. At `360` degrees, the motor angle gets set back to `0`. So, one and a half turns adds up to `540` degrees of total rotation but the motor only cares about the current angle from `0` degrees which is `180` degrees.
When a motor is started for the first time, or after a reset, it's angle of rotation starts at `0` degrees. A complete rotation (a turn in a full circle) is `360` degrees. At `360` degrees, the motor angle doesn't go back to `0` but keeps counting in degrees. So, one and a half turns adds up to `540` degrees of total rotation.
## Returns
* a [number](/types/number) which is the current angle of rotation for the motor. The value returned is the number of degrees from `0` to `359`.
* a [number](/types/number) which is the current angle of rotation for the motor.
## Example
@ -19,13 +19,13 @@ Reset the motor connected to port **A** and run it for for 2 seconds at a speed
```blocks
let motorAngle = 0;
motors.largeA.reset()
motors.largeA.setSpeed(45)
loops.pause(2000)
motors.largeA.run(45)
pause(2000)
motors.largeA.stop()
motorAngle = motors.largeA.angle()
```
## See also
[tacho](/reference/motors/motor/tacho), [speed](/reference/motors/motor/speed),
[speed](/reference/motors/motor/speed),
[reset](/reference/motors/motor/reset), [clear counts](/reference/motors/motor/clear-counts)

View File

@ -15,13 +15,13 @@ See if the motor turns the same number of times for each of two count periods. R
```blocks
let tachoCount = 0;
motors.largeA.reset()
motors.largeA.setSpeed(50)
loops.pause(10000)
tachoCount = motors.largeA.tacho()
motors.largeA.run(50)
pause(10000)
tachoCount = motors.largeA.angle()
motors.largeA.clearCounts()
motors.largeA.setSpeed(50)
loops.pause(10000)
if (tachoCount == motors.largeA.tacho()) {
motors.largeA.run(50)
pause(10000)
if (tachoCount == motors.largeA.angle()) {
brick.showString("Motor turns equal.", 1)
} else {
brick.showString("Motor turns NOT equal.", 1)
@ -31,5 +31,5 @@ motors.largeA.stop()
## See also
[tacho](/reference/motors/motor/tacho), [angle](/reference/motors/motor/angle),
[angle](/reference/motors/motor/angle),
[speed](/reference/motors/motor/speed), [reset](/reference/motors/motor/reset)

View File

@ -13,13 +13,13 @@ The motor's speed is set back to `0` and the **tacho**, **angle**, and **speed**
See what the angle count is when a motor is stopped. Then, try it again after a reset.
```blocks
motors.largeA.setSpeed(30)
loops.pause(2000)
motors.largeA.run(30)
pause(2000)
motors.largeA.stop()
brick.showString("Angle count:", 1)
brick.showNumber(motors.largeA.angle(), 2)
motors.largeA.setSpeed(30)
loops.pause(2000)
motors.largeA.run(30)
pause(2000)
motors.largeA.reset()
brick.showString("Angle count:", 4)
brick.showNumber(motors.largeA.angle(), 5)

View File

@ -1,9 +1,9 @@
# set Speed
# run
Set the rotation speed of the motor as a percentage of maximum speed.
```sig
motors.largeA.setSpeed(50)
motors.largeA.run(50)
```
The speed setting is a pecentage of the motor's full speed. Full speed is the speed that the motor runs when the brick supplies maximum output voltage to the port.
@ -19,28 +19,28 @@ If you use a number of milliseconds as movement units, then you don't need to in
To run the motor for 500 milliseconds:
```block
motors.largeA.setSpeed(50, 500)
motors.largeA.run(50, 500)
```
## ~
Here is how you use each different movement unit to run the motor for a fixed rotation distance.
```typescript
```blocks
// Run motor for 700 Milliseconds.
motors.largeA.setSpeed(25, 700, MoveUnit.MilliSeconds);
motors.largeA.run(25, 700, MoveUnit.MilliSeconds);
// Run motor for 700 Milliseconds again but no units specified.
motors.largeA.setSpeed(25, 700);
motors.largeA.run(25, 700);
// Run the motor for 45 seconds
motors.largeA.setSpeed(50, 45, MoveUnit.Seconds);
motors.largeA.run(50, 45, MoveUnit.Seconds);
// Turn the motor for 270 degrees
motors.largeA.setSpeed(50, 270, MoveUnit.Degrees)
motors.largeA.run(50, 270, MoveUnit.Degrees)
// Turn the motor at full speed for 9 full rotations
motors.largeA.setSpeed(100, 9, MoveUnit.Rotations);
motors.largeA.run(100, 9, MoveUnit.Rotations);
```
## Parameters
@ -56,7 +56,7 @@ motors.largeA.setSpeed(100, 9, MoveUnit.Rotations);
Turning the motor in the opposite direction (reverse) is simple. Reverse is just a negative speed setting. To drive the motor in reverse at 25% speed:
```block
motors.largeB.setSpeed(-25)
motors.largeB.run(-25)
```
## ~
@ -68,8 +68,8 @@ motors.largeB.setSpeed(-25)
Run the motor connected to port **A** continuously. Pause 20 seconds and then stop the motor.
```blocks
motors.largeA.setSpeed(75)
loops.pause(20000)
motors.largeA.run(75)
pause(20000)
motors.largeA.stop()
```
@ -78,8 +78,8 @@ motors.largeA.stop()
Run the motor connected to port **A** in reverse. Pause 5 seconds and then stop the motor.
```blocks
motors.largeA.setSpeed(-60)
loops.pause(5000)
motors.largeA.run(-60)
pause(5000)
motors.largeA.stop()
```
@ -88,7 +88,7 @@ motors.largeA.stop()
Run the motor connected to port **B** for 35 full rotations and then stop.
```blocks
motors.largeB.setSpeed(50, 35, MoveUnit.Rotations)
motors.largeB.run(50, 35, MoveUnit.Rotations)
```
## See also

View File

@ -19,8 +19,8 @@ Also, you can use the brake to do simple skid steering for your brick.
Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and set the brake.
```blocks
motors.largeA.setSpeed(30)
loops.pause(2000)
motors.largeA.run(30)
pause(2000)
motors.largeA.stop()
motors.largeA.setBrake(true)
```

View File

@ -17,13 +17,13 @@ You use a positive value (some number greater than `0`) to drive you motor in th
Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and switch the direciton of rotation. Run the motor at a speed of `-30`. Watch and see if the motor turns in the same direction as before.
```blocks
motors.largeA.setSpeed(30)
loops.pause(2000)
motors.largeA.run(30)
pause(2000)
motors.largeA.stop()
loops.pause(2000)
pause(2000)
motors.largeA.setInverted(true)
motors.largeA.setSpeed(-30)
loops.pause(2000)
motors.largeA.run(-30)
pause(2000)
motors.largeA.stop()
```

View File

@ -22,11 +22,11 @@ Turn off the speed regulation for the motor connected to port **A**.
```blocks
motors.largeA.setRegulated(false)
motors.largeA.setSpeed(75)
loops.pause(20000)
motors.largeA.run(75)
pause(20000)
motors.largeA.stop()
```
## See also
[set speed](/reference/motors/motor/set-speed), [stop](/reference/motors/motor/stop)
[run](/reference/motors/motor/run), [stop](/reference/motors/motor/stop)

View File

@ -6,7 +6,7 @@ Get the current speed of motor rotation as a percentage of maximum speed.
motors.largeA.speed()
```
The actual speed of the motor is the same or very close to it's current speed setting when the motor is regulated. If not regulated, the actual speed can change from the set speed when a force, or load, is applied to it.
The actual speed of the motor is the same or very close to it's current speed setting when the motor is regulated. If not regulated, the actual speed can change from the speed you told it to run at (your desired or _set point_ speed) when a force, or load, is applied to it.
## Returns
@ -18,10 +18,10 @@ Turn speed regulation off and report the actual speed of the large motor in the
```blocks
motors.largeA.setRegulated(false)
motors.largeA.setSpeed(55)
motors.largeA.run(55)
brick.showString("Actual speed:", 1)
for (let i = 0; i < 30; i++) {
loops.pause(500)
pause(500)
brick.showNumber(motors.largeA.speed(), 3)
}
motors.largeA.stop()
@ -29,5 +29,5 @@ motors.largeA.stop()
## See also
[tacho](/reference/motors/motor/tacho), [speed](/reference/motors/motor/speed),
[speed](/reference/motors/motor/speed),
[reset](/reference/motors/motor/reset), [clear counts](/reference/motors/motor/clear-counts)

View File

@ -13,11 +13,11 @@ The motor stops but any motion caused from previously running the motor continue
Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and wait for 2 seconds, then continue at a speed of `50`.
```blocks
motors.largeA.setSpeed(30)
loops.pause(2000)
motors.largeA.run(30)
pause(2000)
motors.largeA.stop()
loops.pause(2000)
motors.largeA.setSpeed(50)
pause(2000)
motors.largeA.run(50)
```
## See also

Some files were not shown because too many files have changed in this diff Show More