Compare commits

...

528 Commits

Author SHA1 Message Date
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
653d8f6f5c 0.0.93 2018-02-07 01:50:28 -08:00
ac0a9f0710 Various example of LavView vs MakeCode (#309)
* screenshots

* more screenshots

* added pics

* more writup

* more examples
2018-02-07 01:42:46 -08:00
2cce2a39b8 updated colors for motor/math 2018-02-07 01:42:16 -08:00
a337403afa 0.0.92 2018-02-06 23:19:06 -08:00
fd9d118fa4 reversed => Inverted (#308)
* renaming "setReversed" to "setInverted" to match LabView

* fixing samples

* typo
2018-02-06 23:18:36 -08:00
e94ac6f6f1 renaming brick.setLight to brick.setStatusLight (#307)
* renaming brick.setLight to brick.setStatusLight

* updated docs
2018-02-06 22:18:39 -08:00
88c58b4e76 First set of 'motors' topics (#305)
* Start of 'motors' topics

* Draft the 'motor motion' side doc

* Add / update more topics

* Last blast of edits

* Capture some more edits

* Put in movement and steering details
2018-02-06 19:43:50 -08:00
e2eb5f35af upgrading to node.js 8 (#306) 2018-02-06 12:50:39 -08:00
71fe612ced 0.0.91 2018-02-05 16:38:50 -08:00
e58ec06e91 IR button indexing fixes (#303)
* IR remote id fixes

* hiding private api

* fixing indexing of buttons
2018-02-05 15:11:11 -08:00
538493369b adding button class on remote buttons 2018-02-05 13:57:24 -08:00
56dd8e0875 enabling doc checks 2018-02-03 09:11:49 -08:00
1f7ef637b2 Fix links in target 2018-02-03 09:09:10 -08:00
f4f2e0ba0e 0.0.90 2018-02-02 14:19:17 -08:00
22c31c57df fix port bug 2018-02-02 14:19:07 -08:00
6879961297 0.0.89 2018-02-02 13:39:18 -08:00
69fcb7407a Simulator support for remote (#302)
* fixing up state

* upgrading ir simulator

* displaying remote

* updated infrared svg
2018-02-02 13:38:54 -08:00
4dfada877c Implement simulator sensor for ambient and reflected light (#301)
* Initial work

* More stuff

* Stuff

* Stuff

* Hardcoded dashed line

* High and low thresholds

* Use rect bBox

* Add back grabbing hand

* Threshold placement

* Cleanup

* Don't need defs

* pxtarget

* Remove dashed lines for now
2018-02-02 13:24:50 -08:00
b10b636766 0.0.88 2018-02-02 09:48:51 -08:00
ba47fb0589 Support for remote control buttons (#300)
* refactor beacon function inside IR sensor

* towards sim support

* channel labels

* reverting to singletons

* hiding unused apis

* lazy allocation of button instances

* tracking button state

* hook up the state
2018-02-02 09:48:27 -08:00
f36e14fe69 renaming remote button names 2018-02-01 22:33:05 -08:00
8bab919db2 0.0.87 2018-02-01 22:21:15 -08:00
89a82b54dc Ir proximity in simulator (#299)
* support for IR proximity

* fixing build issue

* missing break

* remove auto-start of sensor

* setting mode on onEvent

* flooring slider value

* bump up proximity

* fixing threshold blocks
2018-02-01 22:03:01 -08:00
15ee6ebe9c 0.0.86 2018-02-01 16:46:10 -08:00
9bf50665fc improving the spacing & block names (#298) 2018-02-01 16:21:08 -08:00
f594cdefac add infrared sensor in ev3 library (#296) 2018-02-01 16:18:20 -08:00
5ce7a83f5d 0.0.85 2018-02-01 14:41:42 -08:00
d7ef7c353c typo in generated filter 2018-02-01 14:08:28 -08:00
c7cb300cd9 fixing lights in Edge/Firefox 2018-02-01 14:03:36 -08:00
4e194536d3 0.0.84 2018-01-31 20:10:23 -08:00
570cd7474f upgrade pxt 2018-01-31 20:10:13 -08:00
9ea5597734 0.0.83 2018-01-31 18:10:38 -08:00
2c0cc6a3d7 Use decodebase64 (#295)
* avoid atob directly

* prevent port names to be selected

* updated pxt
2018-01-31 18:10:15 -08:00
08f79c5a1a 0.0.82 2018-01-31 15:39:03 -08:00
f817912e07 bump pxt 2018-01-31 15:38:51 -08:00
603932c2b6 0.0.81 2018-01-31 14:21:45 -08:00
a0907e7229 fixing button down issues on touch/mouse (#294) 2018-01-31 14:21:17 -08:00
635d4a7624 Fixing race condition of button animation (#292) 2018-01-31 11:48:53 -08:00
69d3938d85 0.0.80 2018-01-31 10:04:55 -08:00
f08f9105ba Clean generated files (#289)
* clean generated files

* updating gitingore to drop generated files

* updated package lock
2018-01-31 10:04:40 -08:00
7228cbe1cb updated logo 2018-01-31 09:04:52 -08:00
1ea0a0172a adding highcontrast logo 2018-01-31 08:53:21 -08:00
d548dfb578 moving print ports to examples (#288) 2018-01-31 08:44:58 -08:00
a52ce112dc adding high contrast lego logo 2018-01-31 08:44:35 -08:00
ea956f1a73 Buttons rename (#287)
* renaming up/down/click to released/pressed/bump

* missing images

* fixing signature issue

* updated strings

* white lego logo
2018-01-31 08:28:00 -08:00
ba1b9a54b4 0.0.79 2018-01-30 22:41:37 -08:00
59e39fa76d fixing field width 2018-01-30 22:41:18 -08:00
9187c47e09 0.0.78 2018-01-30 22:22:44 -08:00
fcf91caeb4 Zoom screen (#285)
* always start with full brick layout

* adding 'on start' to template

* render entire board when selected

* zoom brick when clicking on screen

* resize when zooming

* toggle zooming of the brick

* inject close icon when selected

* fix toggling
2018-01-30 22:22:21 -08:00
822227eb48 Brick ref topics 02 (#283)
* Add brick button topics

* Add the rest of the brick api
2018-01-30 20:58:18 -08:00
8a331648d6 Field editor fixes in Firefox (#284)
* fixing speed field picker

* switching to open sans

* alignment-baseline not support in FF
2018-01-30 20:40:41 -08:00
4f70d341e4 Start on the 'brick' api topics (#280)
* Start on the 'brick' api topics

* Add the delay to clear screen example

* Better output for clearsceen example
2018-01-30 17:02:22 -08:00
e06659ab4c removing group icons (#282) 2018-01-30 16:40:08 -08:00
437c36b983 0.0.77 2018-01-30 16:16:07 -08:00
3d73f193a8 fix for #260 (#279) 2018-01-30 16:14:54 -08:00
a71dee2923 rebuild for sampling (#261)
* rebuild for sampling

* bump pxt
2018-01-30 16:01:12 -08:00
9ef5b8d4ad 0.0.76 2018-01-30 11:05:29 -08:00
8aa47f3d1e updated chassis (#250) 2018-01-30 08:49:10 -08:00
02b0716043 0.0.75 2018-01-30 08:28:12 -08:00
188d5b3aa7 threshold query api 2018-01-30 08:27:23 -08:00
16c67f0e30 Refactoring datalog in common packages (#249)
* using datalog from common packages

* upgrading common package link

* updated block signatures

* more docs
2018-01-29 19:46:54 -08:00
104185a41e 0.0.74 2018-01-29 15:21:37 -08:00
73363d11b2 Download dialog (#248)
* download dialog

* updated pxt reference

* typo
2018-01-29 15:21:15 -08:00
61996acdd9 0.0.73 2018-01-29 13:26:46 -08:00
21deb45728 fixing release fiber 2018-01-29 13:26:31 -08:00
34578d2370 0.0.72 2018-01-29 11:20:46 -08:00
3f50b5c39a updated pxt references + hero banner 2018-01-29 11:20:34 -08:00
d371225066 0.0.71 2018-01-23 14:53:09 -08:00
387effbdd0 upgraded to run in parallel 2018-01-23 14:52:41 -08:00
18480080e7 updated tutorial format 2018-01-19 15:42:23 -08:00
bf6a932e5f Color calibration (#245)
* better handling of thresholds, color calibration strategy

* updating calibration parameters
2018-01-19 13:11:11 -08:00
23bb316403 settle robot once brake is applied 2018-01-18 21:28:00 -08:00
138de504e5 minor high contrast fixes 2018-01-18 21:03:57 -08:00
df13e40a45 fixing make it move 2018-01-18 16:47:00 -08:00
511ea2374b fixing summary 2018-01-18 16:44:57 -08:00
db4ed6daf3 fixing a bunch of snippets 2018-01-18 16:43:16 -08:00
a60427e2cf using audio context manager function (#243)
* using audio context manager function

* updated pxt reference

* trigger build
2018-01-18 13:53:33 -08:00
ef5b4172e8 missing file logo 2018-01-18 12:42:11 -08:00
7baf7cfede 0.0.70 2018-01-18 12:13:17 -08:00
efd6718ea3 converted lesson to tutorial 2018-01-18 12:09:43 -08:00
057a1d66dc PID support (#242)
* updated block definitions

* updated dependency on common packages
2018-01-18 10:34:06 -08:00
5ddfcd5508 Prototype lesson 'Make it Move" (#241)
* Prototype lesson 'Make it Move"

* Wrong blockq type
2018-01-17 19:45:07 -08:00
00f0922189 Merge pull request #240 from Microsoft/line-detect-lesson
Prototype lesson for 'Line Detection'
2018-01-17 19:07:29 -08:00
41f4b64087 Add to gallerys 2018-01-17 18:52:49 -08:00
ea5ee1c007 Prototype lesson for 'Line Detection' 2018-01-17 17:02:11 -08:00
603e4c0fc1 0.0.69 2018-01-16 17:06:52 -08:00
e50c88008a updated gyrobox 2018-01-16 17:05:57 -08:00
f057964a50 pausing until sound is done in mood 2018-01-16 16:44:32 -08:00
2eda2061cf updated modified gyro boy 2018-01-16 16:26:49 -08:00
a4ebf4c746 moving moods in separate namespace 2018-01-16 16:21:02 -08:00
f1880897d4 0.0.68 2018-01-16 16:08:53 -08:00
ad2e82060d removing BrickLight blockIdenity notations 2018-01-16 15:59:40 -08:00
d1bb19e30e adding a mood block (image+sound+light) 2018-01-16 14:52:49 -08:00
280963d1eb 0.0.67 2018-01-15 23:58:31 -08:00
9fadf49b0e Support for multiple motors in "used" logic. (#238)
* handle registerion of dual / single motors

* updated puppy
2018-01-15 23:57:21 -08:00
3c2be25384 some core set adapted codes 2018-01-15 21:27:19 -08:00
e1f623a94d Added description to timers 2018-01-15 03:41:14 -08:00
cb5f9648f5 fixed sound name 2018-01-14 19:49:40 -08:00
9158cfe4f6 0.0.66 2018-01-13 08:31:38 -08:00
0b763978f2 gyro boy improvements (#236)
gyro boy improvements
2018-01-13 08:31:10 -08:00
25fded6afb 0.0.65 2018-01-13 00:02:01 -08:00
fc6fb0811f Timers (#235)
* adding timer support

* updates strings
2018-01-13 00:00:55 -08:00
49bedcbcc5 0.0.64 2018-01-12 16:12:02 -08:00
32876f4584 Merge pull request #234 from Microsoft/largemotorview
Fix large motor SVG hole
2018-01-12 13:51:00 -08:00
da9bea30b5 Update large motor view SVG so that the drop shadow is outside the hole SVG 2018-01-12 13:50:09 -08:00
d0aa68aeee 0.0.63 2018-01-12 13:33:45 -08:00
51731fbbc9 bump pxt-common-packages to 0.15.5, 2018-01-12 13:33:40 -08:00
751ea1494b motor slider fixes and fix motor output in vm 2018-01-12 13:33:25 -08:00
dfe84471e8 Merge pull request #144 from Microsoft/motorslider
Add motor slider control
2018-01-12 13:04:45 -08:00
0f3de6cf07 0.0.62 2018-01-11 22:56:34 -08:00
21195e4abf Datalog (#233)
* support for custom csv separator

* simple datalog frameowrk

* api strings

* hide setfile

* storage fixes

* log seconds, not milliseconds
2018-01-11 22:53:28 -08:00
c992100a38 added option to append CSV headers 2018-01-11 21:36:43 -08:00
20a4673f98 First draft of storage APIs (#122)
* First draft of storage APIs

* bumped pxt-core

* using fixed instances to seprate temp from permanent

* send console to storage

* sim support

* missing sim stubs

* adding storage blocks

* more sim support

* remove storage from default package

* fix rendering of ms

* render raw ms

* slize at better place

* duplicate bundled dir

* refactor limit

* simplify limit logic
2018-01-11 20:05:45 -08:00
966fd81870 0.0.61 2018-01-11 14:08:14 -08:00
cb9d2aeb39 bumping pxt dependency 2018-01-11 14:08:01 -08:00
3cee55f4c2 0.0.60 2018-01-11 13:43:41 -08:00
3815d2fd3b simplifiying brick light api (#231) 2018-01-11 13:43:11 -08:00
1453b7e0a3 gyro reset fix 2018-01-11 11:17:23 -08:00
6fb5c54280 fix build break 2018-01-11 08:55:31 -08:00
9d5ca35e83 fix battery encoding 2018-01-11 08:47:09 -08:00
893dd0f9c4 rename "enter..." to "button enter" 2018-01-11 08:28:25 -08:00
c3419c0b74 support for unregulated motors (#227) 2018-01-10 23:34:27 -08:00
a4164470d8 updated api to align with labview 2018-01-10 22:29:35 -08:00
0dd5ab9bde appliying manual speed 2018-01-10 14:08:50 -08:00
e93e659e8a nit: remove unnecessary comment 2018-01-10 13:51:35 -08:00
8357372fb5 Update to make it more like a crank 2018-01-10 13:47:39 -08:00
54cb076002 Merge pull request #226 from Microsoft/legoavatar
Add lego avatar
2018-01-10 13:03:15 -08:00
dbd3eb464b Add lego avatar 2018-01-10 12:59:53 -08:00
10cd39a4ec Merge branch 'master' into motorslider 2018-01-10 12:52:51 -08:00
fddc4e647a 0.0.59 2018-01-10 12:52:48 -08:00
798a351f15 updated package lock 2018-01-10 12:52:36 -08:00
e61dffff03 fixing threshold 2018-01-10 11:45:08 -08:00
b9f5096480 pause until motor measured move is done 2018-01-10 11:29:27 -08:00
9912d68c8b fixing chassis 2018-01-10 11:14:25 -08:00
951b9be6e4 fixing motors 2018-01-10 11:14:18 -08:00
aa8635c4e7 Always use the motor slider control 2018-01-10 10:00:48 -08:00
4e4f5495da Merge branch 'master' into motorslider 2018-01-10 09:56:59 -08:00
f64bf57000 Merge master 2018-01-10 09:56:32 -08:00
f1242724b5 Fix legofont icons 2018-01-10 09:55:58 -08:00
cd0c9df86e bump to 3.0.8 2018-01-10 08:58:54 -08:00
337d42287a 0.0.58 2018-01-09 22:14:43 -08:00
ce3383f1b7 Turn ratio field editor (#225)
* Turn ratio field editor (initial draft)

* Add field turn ratio editor

* Fix arrow rotation

* Fix left and right direction, remove unnecessary SVG circles.

* Update UI a little. add marker.

* updated math for turnratio angle

* slightly cuter

* cleanup

* consistent naming

* more cleanup

* fixing motor node issue

* updated package version
2018-01-09 22:05:26 -08:00
e51721303a Merge pull request #224 from Microsoft/fixportlabels
Fix port labels in the simulator.
2018-01-09 14:43:26 -08:00
50f6c77fdb Fix port labels in the simulator. Fixes #219 2018-01-09 14:43:01 -08:00
5ed0135124 cleaning up images (#223)
* cleaning up images

* extra comma
2018-01-09 12:51:44 -08:00
892a2d585f Thresholds (#222)
* add threshold blocks

* updated strings

* added gap

* reorg color/gyro blocks

* fixing sound names

* adding stop block

* fixing exanmples
2018-01-09 12:46:48 -08:00
9890f2340a Add no-drag class and set on synced motor labels. Fixes #213 (#221) 2018-01-09 12:04:37 -08:00
109b809909 Sort field port values. Fixes #212 (#220) 2018-01-09 12:01:42 -08:00
9cbf5efd7e 0.0.57 2018-01-08 22:01:11 -08:00
a27a7fcd55 removing measured overloads until blocks support (#215) 2018-01-08 15:27:37 -08:00
85263fb84d Merge branch 'master' of https://github.com/Microsoft/pxt-ev3 2018-01-08 15:13:20 -08:00
b5ad898c9e Screentweak (#214)
* adding pid

* hiding functions

* precision of value
2018-01-08 15:00:00 -08:00
456df3c442 Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-01-08 14:43:19 -08:00
1552eb05b4 matter most info 2018-01-08 14:43:15 -08:00
d60e2c4a7d adding pid 2018-01-08 14:36:34 -08:00
f4b78c3ee7 PID example 2018-01-08 14:06:39 -08:00
dd5e1957d5 fix coding page 2018-01-08 14:06:29 -08:00
d61a63f70a avoid overlaps in port view 2018-01-08 09:08:59 -08:00
4207bd06c0 removing microbit font 2018-01-08 08:53:03 -08:00
58763e398b 0.0.56 2018-01-07 23:39:04 -08:00
f77bf165eb updates strings 2018-01-07 20:51:48 -08:00
4880d9ea5b Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-01-07 20:45:56 -08:00
ab4fb019f9 more changes to "print" 2018-01-07 20:45:48 -08:00
2c2df31ba3 Merge pull request #205 from Microsoft/motorshuffle
shuffling motor blocks
2018-01-07 20:34:20 -08:00
0f2bda2496 shuffling motor blocks 2018-01-07 20:33:02 -08:00
44386be3c7 Merge pull request #185 from Microsoft/printlineinverted
invert arguments in print line
2018-01-07 12:14:16 -08:00
89ca66b8a9 Merge pull request #201 from Microsoft/speedfield
Add a speed field editor
2018-01-07 12:11:40 -08:00
64389a7689 more annotations 2018-01-07 10:06:02 -08:00
f77778ef85 Merge branch 'master' into speedfield 2018-01-07 09:59:11 -08:00
7d01823caf remove stopAllMotors on escape key 2018-01-07 09:58:08 -08:00
b3f9a4c92f Make sure we stop motors on exit (#199) 2018-01-07 07:54:40 -08:00
7fe8580de8 Add brick buttons field editor (#202)
* Add brick buttons field editor

* add hover title text
2018-01-07 07:52:07 -08:00
c70d6fe01a Remove unnecessary extra 'light' text in block pauseUntilLight (#203) 2018-01-07 00:12:29 -08:00
ed7099cc97 more square shaped corners 2018-01-06 21:00:39 -08:00
a79704fecc Decompilation and minor PR feedback 2018-01-06 17:16:08 -08:00
6a1b560101 Fix default 2018-01-06 14:40:09 -08:00
5e21f9ab6d Add a speed field editor 2018-01-06 14:25:50 -08:00
74648bd1df Merge pull request #198 from Microsoft/moresquarecorners
More square shaped corners on blocks
2018-01-06 12:55:51 -08:00
e24d4d56b1 More square shaped corners on blocks (toggle rect and arrow corner) 2018-01-06 00:12:32 -08:00
0345277bef 0.0.55 2018-01-06 00:00:40 -08:00
9ae6482f28 fixing isReady query on motors (#197) 2018-01-06 00:00:04 -08:00
77fb64043d stop all motors when pressing escape 2018-01-05 22:56:11 -08:00
f875681661 added roaming 2018-01-05 22:04:18 -08:00
fbb1fa688d fixing gallery 2018-01-05 21:50:50 -08:00
485f02ed27 cruise control activities 2018-01-05 21:49:04 -08:00
81f406c6cc ignition activities 2018-01-05 21:40:11 -08:00
ac0a7b326f 0.0.54 2018-01-05 21:30:05 -08:00
c814728354 pdated ultrasonic default 2018-01-05 21:29:52 -08:00
abeb378b17 reverse beeper 2018-01-05 21:20:00 -08:00
6928f9e50e traffic lights activity 2018-01-05 19:28:24 -08:00
931987468a light the way activities 2018-01-05 19:14:55 -08:00
94c4e508fe reversing the robot 2018-01-05 18:36:20 -08:00
ea46f1cbc7 3 activies from curriculum (#194)
* 3 activies from curriculum

* fixing style
2018-01-05 18:24:23 -08:00
9f9ce29476 Merge branch 'master' of https://github.com/Microsoft/pxt-ev3 2018-01-05 17:35:47 -08:00
50f6b04ed4 Re-implement Math.sign so it works on IE 11 (not supported). Square shaped corners for Flyout 2018-01-05 17:35:25 -08:00
64d6c2b090 Motors cleanup (#192)
* refactoring

* moving chassis into separate project

* added set motors
2018-01-05 16:02:52 -08:00
76ff39605a Remove synced motor label when motors are no longer in sync (#189) 2018-01-05 10:54:42 -08:00
2d3ea5631a Merge pull request #190 from Microsoft/consoleicon
Add console icon and set color.
2018-01-05 10:38:52 -08:00
e938f354fd Add console icon and set color. Fixes #152 2018-01-05 10:38:26 -08:00
886464b470 Merge branch 'master' of https://github.com/microsoft/pxt-ev3 2018-01-05 08:47:26 -08:00
b9ff9d21f1 bump common packages 2018-01-05 08:47:22 -08:00
aa06fd344a store synched motor info always (#187) 2018-01-05 08:40:49 -08:00
dc6ce0efc7 0.0.53 2018-01-05 08:39:30 -08:00
4039a85bc9 Make sure the ESC button always stops the program 2018-01-05 16:17:33 +00:00
7bd6280292 Disable HID deploy from command line (seems broken; was crashing until my previous checkin) 2018-01-05 16:17:20 +00:00
2ebe96e563 Fix command line deploy 2018-01-05 15:33:09 +00:00
a9be582f90 gyro calibration done right (#186) 2018-01-04 23:21:19 -08:00
ac428a3936 invert arguments in print line 2018-01-04 22:13:17 -08:00
de91dc6ab7 Handle the case where multiple motors or multiple sensors are connected to the same port. (#181) 2018-01-04 21:57:01 -08:00
1e460eef9e basic reading of battery level (#182) 2018-01-04 21:50:13 -08:00
0db6987ee5 Add loader and animation (#180) 2018-01-04 16:17:14 -08:00
148657908c Merge pull request #179 from Microsoft/syncedmotorui
Synced motors label (in simulator)
2018-01-04 14:38:29 -08:00
f3f87331c8 nit 2018-01-04 14:09:10 -08:00
5aef77ccc6 Generalizing motorView for both medium and large motor views. Initial work towards synced motor views. Adding sync label for controller motor. 2018-01-04 14:03:50 -08:00
59ca9cf463 0.0.52 2018-01-04 13:04:23 -08:00
7da811246c Behaviors Driven Robotics (#178)
* adding avoid crash behavior

* more implementation

* add another simple behavior

* fixed synched motors

* bump common packages
2018-01-04 12:55:30 -08:00
69f8453947 Merge pull request #177 from Microsoft/sounds_bug_fix
Fix stopAllSounds simulator bug
2018-01-04 12:52:17 -08:00
39ba9b81af Initial work 2018-01-04 12:20:31 -08:00
51a14596cd 0.0.51 2018-01-04 11:41:49 -08:00
8518c446cd Merge pull request #176 from Microsoft/iefonticons
Fix font icons on IE, and add package icon on Windows
2018-01-04 11:40:42 -08:00
2f69df0d9d Fix font icons on IE, and add package icon on Windows 2018-01-04 11:39:20 -08:00
1789d0ce21 Lowercase menubar titles. 2018-01-04 10:42:37 -08:00
d0809510c4 Merge pull request #174 from Microsoft/addbetatag
Add beta tag.
2018-01-04 10:14:43 -08:00
6b9c0eaf65 Add beta tag. #150 2018-01-04 10:14:11 -08:00
52bdf94233 Merge pull request #173 from Microsoft/blockiconfont
Add block icon font
2018-01-04 09:57:11 -08:00
fd50ed8f7c Add block icon font 2018-01-04 09:52:12 -08:00
ba0eb93b0f use common packages tests implementation (#171) 2018-01-04 09:23:28 -08:00
9a4ed45797 0.0.50 2018-01-04 09:19:33 -08:00
820fdf3a3c Merge pull request #172 from Microsoft/fixwinicons
Fix check and cancel icons on windows
2018-01-04 09:18:30 -08:00
348d5ffc26 Fix check and cancel icons on windows 2018-01-04 09:17:30 -08:00
95e47a0b25 Merge pull request #169 from Microsoft/screenimgeditor
Initial screen field editor.
2018-01-04 08:37:56 -08:00
c3312ed5d1 Merge pull request #170 from Microsoft/clearcounts
moving motor blocks around
2018-01-04 08:37:39 -08:00
b7cdc7d0fe moving blocks around 2018-01-04 08:25:02 -08:00
dde5a35cd9 Initial screen field editor. Adding Lego designer assets to legoresources 2018-01-03 17:20:35 -08:00
be398d84ee Merge pull request #135 from Microsoft/field_ports
Add an output port field editor
2018-01-03 17:07:34 -08:00
4445acce7a Split editor extensions into multiple module loaded files. Re-using editor/deploy.ts for cmds. Fixing field ports 2018-01-03 16:18:39 -08:00
d6d8b0655b Merge branch 'master' into field_ports 2018-01-03 15:12:35 -08:00
216aa1ddaf Fix save icon 2018-01-03 15:07:45 -08:00
783a561941 0.0.49 2018-01-03 15:02:35 -08:00
c916664ae7 Fix download and save icons. 2018-01-03 15:02:24 -08:00
4b836ede1b Merge pull request #167 from Microsoft/blockfixes
Block layout fixes.
2018-01-03 14:22:18 -08:00
52fdaeec99 remove colon from print line block 2018-01-03 14:22:00 -08:00
2aaa45e10d Merge pull request #168 from Microsoft/remainingiconfixes
Remaining icon fixes.
2018-01-03 14:21:04 -08:00
7993363e89 Remaining icon fixes. Using blockIcons to show custom icons for built in categories 2018-01-03 14:20:33 -08:00
4d671f6cb0 Block layout fixes. Fixes to screen blocks. Adding print line API. 2018-01-03 14:00:08 -08:00
cc020d5a81 Merge pull request #124 from Microsoft/icon_font
Icon font
2018-01-03 12:35:52 -08:00
5c39862a44 Fix the rest of the icons (sensors, math, variables and extensions) 2018-01-03 12:35:33 -08:00
e0e5c95989 Merge branch 'master' into icon_font 2018-01-03 11:56:28 -08:00
800b4ad224 Merge pull request #165 from Microsoft/fixnullrefthis
Fix null ref for this when _update is called.
2018-01-03 11:42:38 -08:00
40c3b4b0cf Tweaking sensor icon 2018-01-03 11:36:43 -08:00
64bdc35e6f Merge paths for sensor icon 2018-01-03 11:29:49 -08:00
2b5f702bb6 Fix null ref for this when _update is called. 2018-01-03 11:20:37 -08:00
1c81ecd23f send ports data to console 2018-01-03 08:24:54 -08:00
4d223374b5 Differential drive (#164)
* clear sync speed cmd

* differential drive model

* use cm/s

* fixed aggressive clearing of motor sync command

* better computation of turn artio

* improved robot dimensions

* moving block up

* hanbdle infinite case

* correct handling of inifinte time/step

* better stop handling
2018-01-03 00:27:05 -08:00
dd9cf9014f Merge pull request #163 from Microsoft/fixnullderefbuttons
Fix null dereferencing issue for buttons
2018-01-02 23:19:55 -08:00
eb11d7926c Fix null dereferencing issue for buttons 2018-01-02 23:18:54 -08:00
609740dc48 Merge pull request #162 from Microsoft/moresensorfixes
Better fix for null dereferencing issue.
2018-01-02 22:51:45 -08:00
955a2c9757 Better fix for null dereferencing issue. Fix initial Color sensor mode (default). 2018-01-02 22:51:12 -08:00
02838e6c30 Merge pull request #161 from Microsoft/colorgridfixes
Update Color sensor control (colorGrid) to match spec
2018-01-02 22:30:04 -08:00
b0c54e84e6 Update Color sensor control (colorGrid) to match spec 2018-01-02 22:29:12 -08:00
b6644b7a23 Merge pull request #160 from Microsoft/sensorfixes
Sensor fixes. Fix race condition
2018-01-02 22:23:14 -08:00
3c4c38eb59 Fix null dereferencing issue. Fix sensor mode changed not clearing cached control. 2018-01-02 22:22:14 -08:00
29aba7b10b Fix advanced icons 2018-01-02 17:30:19 -08:00
7427142243 Merge branch 'icon_font' of https://github.com/Microsoft/pxt-ev3 into icon_font 2018-01-02 17:17:13 -08:00
436500babb Merge 2018-01-02 17:11:24 -08:00
82be4e344b More work 2018-01-02 17:07:36 -08:00
81bfca4ed6 0.0.48 2018-01-02 16:20:30 -08:00
c35dbdd38f Motor sync support in simulator (#159)
* parse sync motor command

* better sim support

* sync support

* fixing tank
2018-01-02 16:20:00 -08:00
1bc93013e6 0.0.47 2018-01-02 14:51:00 -08:00
58148eb1c3 Square shaped corners for Blockly blocks and dropdowns. (#158) 2018-01-02 13:32:07 -08:00
a7c62b45b2 Use legoIcons font for flyout headings 2018-01-02 13:01:28 -08:00
bd765d49ee Add lego resources.AI 2018-01-02 12:59:48 -08:00
383ca5467d Remove advexpanded/advcollapsed 2018-01-02 12:49:25 -08:00
e240e3b394 Check, cancel 2018-01-02 10:47:04 -08:00
7affbf8cb6 Save, download 2018-01-02 10:47:04 -08:00
4dff282633 Initial work 2018-01-02 10:47:04 -08:00
5d470fdcef Merge pull request #143 from Microsoft/persistselected
Persist selected state of controls across simulator restarts
2017-12-29 14:02:50 -08:00
16b9a5027d Add rotate icons 2017-12-29 11:39:06 -08:00
cbe68b3199 Add motor slider control 2017-12-28 13:23:30 -08:00
f30eac41e9 Persist selected state of controls across simulator restarts 2017-12-28 11:17:18 -08:00
d7f46c0fb5 Hide screen picker properly from typescript 2017-12-28 11:15:53 -08:00
58384017f2 0.0.46 2017-12-28 09:08:27 -08:00
01f7fe633c Motorworks2 (#141)
* fixing polarity

* allocate motor on motorUsed only

* perform sub-step integration step for better precision
2017-12-28 09:07:57 -08:00
a9a9a89811 Better fonts and better alignment of motor reporter control 2017-12-27 20:43:39 -08:00
7e2251d8ac Fix negative motor reporting 2017-12-27 20:35:36 -08:00
1903a6e347 Merge pull request #140 from Microsoft/motorreporters
Add motor reporter control
2017-12-27 20:32:53 -08:00
2fb75a2d83 Added todo 2017-12-27 17:07:50 -08:00
0da175a8cd Add motor reporter control 2017-12-27 17:06:23 -08:00
f01370e4fd Simulator support for motor commands (#137)
* support for "step" functions

* locale files

* enum issue

* fixing decoding of array

* implement clear count

* log unknown commands
2017-12-27 17:05:15 -08:00
751df2fe8c Merge pull request #139 from Microsoft/colorandsliderresizefixes
Fix resizing in controls to work for all sizes including full screen
2017-12-27 16:31:20 -08:00
8be4bb11d8 Fix resizing in controls to work for all sizes including full screen 2017-12-27 16:30:42 -08:00
342e714ae2 Merge pull request #138 from Microsoft/updatemotorassets
Update motor SVG assets and connections
2017-12-27 14:48:50 -08:00
fb31b81f7e Update motor SVG assets and connections 2017-12-27 14:48:15 -08:00
8204995749 Fix wire view to match spec size of wires. 2017-12-26 23:28:29 -08:00
85c14bb05a Fix rotation and distance slider update state 2017-12-26 23:23:26 -08:00
c398a5a133 Update padding and fix wiring order 2017-12-26 23:19:04 -08:00
a1b059171b Add a output port field editor 2017-12-24 17:46:58 -08:00
afaedaa0b2 Merge pull request #134 from Microsoft/fixflickering
Fix resizing flickering issue in the simulator
2017-12-24 16:19:36 -08:00
0aa41e9a64 Fix resizing flickering issue, remove flip animation on start, remove the need for a default height and width in the layout engine 2017-12-24 11:59:01 -08:00
88df2e14cb Merge pull request #125 from Microsoft/sim_refactor_resize
Refactor sim for better resizing and support for multiple controls to be open
2017-12-22 14:01:35 -08:00
180f32f25c Simulator refactoring to support better resizing of modules and controls 2017-12-22 14:00:23 -08:00
995527675a Check, cancel 2017-12-21 11:30:32 -08:00
84eb849bc7 Save, download 2017-12-21 11:10:47 -08:00
5e0e35b4bd Initial work 2017-12-21 11:00:54 -08:00
300a2c1476 Merge pull request #123 from Microsoft/gradient_circle
Gradient circle
2017-12-20 16:34:59 -08:00
703bd01931 Increase stroke width 2017-12-20 16:25:26 -08:00
75a65eeab2 Add lego icons 2017-12-20 16:16:13 -08:00
38a9f153f7 pxtarget 2017-12-20 15:15:12 -08:00
3c5dae8c7b Small changes 2017-12-20 15:11:44 -08:00
85345969d3 Initial work 2017-12-20 14:58:41 -08:00
ac1e5d2846 Remove constant resize 2017-12-19 21:20:06 -08:00
11b4bbc07e Fix controls 2017-12-19 17:20:01 -08:00
7f5b8aed99 more tweaking of angle encoding 2017-12-19 17:15:53 -08:00
c989e2fdab Merge pull request #121 from Microsoft/motorphysics
Motor work
2017-12-19 17:07:15 -08:00
d3dcb5de85 Use setChangedState for touch and color sensors 2017-12-19 17:01:45 -08:00
9cca35d49f encoding 32bit angle into data buffer 2017-12-19 16:54:44 -08:00
7123bfecd3 removing cancel animation stuff 2017-12-19 16:21:14 -08:00
c8ac770983 read motor state into lms_motor 2017-12-19 16:18:17 -08:00
aa031036ee updating motor state in game loop 2017-12-19 16:03:26 -08:00
a7d002d949 0.0.45 2017-12-19 15:10:32 -08:00
93fd8c8c78 removing more icons 2017-12-19 15:10:13 -08:00
1765ca2d35 Merge pull request #116 from Microsoft/revert_screenopt
Use game loop instead of animation queue
2017-12-19 14:58:37 -08:00
1ab7ae6cfa minor PR feedback 2017-12-19 14:57:28 -08:00
3acf4e9ac5 More hardware tests (#119) 2017-12-19 14:55:48 -08:00
ef5fa9ae82 Minor fix to killing the animation when the sim is killed 2017-12-19 14:55:43 -08:00
e1f7a5b8cf Merge pull request #118 from Microsoft/ambient_light_threshold
Set high/low to 20/5 for ambient light mode
2017-12-19 14:42:54 -08:00
2c73bfc813 Set high/low to 20/5 2017-12-19 14:40:30 -08:00
d78d9c8686 basic ports view (#115)
* basic ports view

* slight adjustement of rendering
2017-12-19 14:26:57 -08:00
2157af3e63 Using game loop instead of queueAnimationUpdate 2017-12-19 14:20:35 -08:00
eac3e183c3 better test support 2017-12-19 13:10:40 -08:00
785ddff706 Reverting screen optimization to use SetInterval and didChange 2017-12-19 12:53:12 -08:00
e07d6e3a31 0.0.44 2017-12-19 11:53:50 -08:00
763ad3f763 0.0.43 2017-12-19 11:38:02 -08:00
919a03951c Removing icons (#114)
* removing icons

* added "pause for light"
2017-12-19 11:37:33 -08:00
9e427898ae added test framework (#113)
* added test framework

* added toString on motors

* enabling logs
2017-12-19 07:07:50 -08:00
60bf3a17d3 a mini-console support with scroll up / down (#112)
* a mini-console support with scroll up / down

* fix compile error
2017-12-18 22:36:32 -08:00
0529759a80 Fix ultrasonic value to use cm instead of 0.1 cm units (#110)
* Fix simulator

* use 250 instead of 255
2017-12-18 20:30:56 -08:00
b07f157181 0.0.42 2017-12-18 18:24:46 -08:00
2f5f7d4133 Merge pull request #111 from Microsoft/scale_screen
Add tiny padding around the screen for the canvas.
2017-12-18 17:08:02 -08:00
e6e1dce59f Add tiny padding around the screen for the canvas. 2017-12-18 17:07:23 -08:00
43a9d03231 fixing pauseUntilReady signature 2017-12-18 14:45:44 -08:00
c0f6cd3651 test passing on hw 2017-12-18 14:31:17 -08:00
f1445c6e89 Motor pause until ready (#108)
* adding command to pause until ready

* adding console API

* adding ready support for motors

* fix time output scale

* fixing angle
2017-12-18 14:13:38 -08:00
04275ee35c 0.0.41 2017-12-18 13:22:13 -08:00
f8d0594eca Merge pull request #107 from Microsoft/initial_sim
Initial sim implementation
2017-12-18 13:21:48 -08:00
5be3b31e00 Merge branch 'master' into initial_sim 2017-12-18 13:21:35 -08:00
84c1079e50 Fix Safari bug. 2017-12-18 13:19:49 -08:00
6320379d02 Initial sim implementation 2017-12-18 13:04:17 -08:00
b166f6034e storing test 2017-12-18 09:43:44 -08:00
d07f672b28 fixing single motor set speed 2017-12-18 09:17:19 -08:00
363e076f36 fixing motor compilation 2017-12-18 08:54:53 -08:00
8bf6f265f7 Merge pull request #105 from Microsoft/motorfixes
Motor fixes
2017-12-18 00:54:53 -08:00
217958aec3 fix polarity 2017-12-17 23:19:38 -08:00
367b1b0d1a properly setting multiple-motor options 2017-12-17 23:00:07 -08:00
6836852122 refactoring motors wiht base class (#104) 2017-12-17 22:47:13 -08:00
944098b9f9 Minor refactor fix (#102)
* Minor fix to a refactor of motor output this.brake to this._brake

* No (_this) in global context

* Minor fix
2017-12-17 21:12:18 -08:00
539cf3d73e 0.0.40 2017-12-15 14:30:51 -08:00
4b3e7cfb7d bump pxt-core to 3.0.2, bump pxt-common-packages to 0.14.13, 2017-12-15 14:30:43 -08:00
b144744509 Add tsconfig.json for easier library editing (#96) 2017-12-15 14:29:31 -08:00
e591bed6ad Add 'clear screen' block to brick category (#100) 2017-12-15 14:29:10 -08:00
6a4e64eac0 Merge pull request #79 from Microsoft/motorsync
Motor sync block
2017-12-15 14:28:03 -08:00
f7dd14ff7b Merge pull request #88 from Microsoft/even_more_sounds
Add 'stopAllSounds' block
2017-12-15 11:36:31 -08:00
bfd34cedd6 Update built files 2017-12-15 11:04:16 -08:00
8e1c075911 Merge pull request #98 from Microsoft/portFixes
Fix order of color and ultrasonic sensor ports.
2017-12-15 10:45:34 -08:00
a02f364a4c Update function names for consistency 2017-12-15 10:42:44 -08:00
48fee2c215 Merge pull request #99 from Microsoft/ui_changes
Some UI theming. square buttons
2017-12-15 08:55:45 -08:00
5780d1982c Some UI theming. square buttons 2017-12-15 08:55:21 -08:00
6fb08f0f7b Fix order of color and ultrasonic sensor ports. 2017-12-15 07:48:42 -08:00
13f8659b98 Merge pull request #97 from Microsoft/startup_delay
Startup delay for sensors to get values
2017-12-15 07:05:21 -08:00
edc9d17a8c Merge pull request #95 from Microsoft/serialnumber
Implement getSerialNumber (based on BT MAC)
2017-12-15 07:04:21 -08:00
c7a3f5bbd0 Delay user code by 100ms to get sensor reading (fixes #90) 2017-12-15 11:55:20 +00:00
41d5052583 Run sensor "change handler" also with the initial value 2017-12-15 11:54:53 +00:00
07ddec343a Formatting 2017-12-15 11:30:15 +00:00
5a9a5e997a Error reporting fixes 2017-12-15 11:29:18 +00:00
55b6549999 Implement getSerialNumber (based on BT MAC) 2017-12-15 11:25:23 +00:00
fcdc350e40 more motor work 2017-12-14 17:01:23 -08:00
9dedbeae1b updated parameters 2017-12-14 13:26:04 -08:00
124d8a0fd8 tank support 2017-12-14 13:25:27 -08:00
81fcbb6916 tweaks of blocks 2017-12-14 13:07:10 -08:00
d436bd1227 Fix simulator stop() method 2017-12-14 09:41:01 -08:00
cb648019bb Progress 2017-12-14 09:17:47 -08:00
11a88a9d94 updated signatures 2017-12-13 23:00:37 -08:00
92178f3371 bring back speed 2017-12-13 22:54:08 -08:00
3c86ae286f more work on motors 2017-12-13 22:40:40 -08:00
1b6d84a9b8 Merge branch 'master' into motorsync 2017-12-13 21:16:33 -08:00
2d81be3b24 Add 'stopAllSounds' block 2017-12-13 16:31:42 -08:00
14f57f54bf Merge pull request #87 from Microsoft/motor_fix_2
Motor data fix
2017-12-13 15:56:17 -08:00
e7c697c24d Merge pull request #85 from Microsoft/on_color_fix
Fix "on color detected" block
2017-12-13 15:55:47 -08:00
7ac63f038c Merge pull request #84 from Microsoft/fix_image_attrs
Adding block identity
2017-12-13 15:55:36 -08:00
557926d631 Merge pull request #78 from Microsoft/waitUntiltopauseUntil
renaming all "wait until" to "pause until"
2017-12-13 15:52:46 -08:00
da62d51615 Merge branch 'master' into motor_fix_2 2017-12-13 15:48:43 -08:00
3918857fcc Merge branch 'master' into on_color_fix 2017-12-13 15:48:24 -08:00
f1dcebdd88 Merge branch 'master' into fix_image_attrs 2017-12-13 15:48:09 -08:00
1d35c78737 Merge branch 'master' into motorsync 2017-12-13 15:47:52 -08:00
d17326ad7a Merge branch 'master' into waitUntiltopauseUntil 2017-12-13 15:47:27 -08:00
4948a88833 Merge pull request #83 from Microsoft/new_ts_cleanup
New ts cleanup
2017-12-13 15:46:58 -08:00
b73b924ec4 ignoreing docs errors 2017-12-13 15:35:53 -08:00
641d292c33 Clean commit for motor fix 2017-12-13 14:55:14 -08:00
223275fd65 Moving a line of code 2017-12-13 13:35:28 -08:00
6e42e816d3 Adding block identity 2017-12-13 10:42:49 -08:00
5678cf5df9 Fixing test file 2017-12-13 10:29:12 -08:00
67ec4accb9 Monitor memory usage and panic on over 8MB used 2017-12-13 15:28:52 +00:00
fa867c3a34 Cleanup 2017-12-12 15:24:36 -08:00
7865876e64 Merge branch 'master' into waitUntiltopauseUntil 2017-12-12 14:19:35 -08:00
113b42656c sync command working 2017-12-12 14:08:45 -08:00
7557380722 adding sync command 2017-12-12 13:20:25 -08:00
3e2a1ec9e1 missing strings files 2017-12-12 11:23:29 -08:00
09db613620 updated docs 2017-12-12 10:49:45 -08:00
bacb4673c9 renaming all "wait until" to "pause until" 2017-12-12 10:46:56 -08:00
e649a167cd Merge pull request #74 from Microsoft/powertospeed
some speed renamings
2017-12-11 23:20:17 -08:00
997e8efb20 Merge branch 'master' of https://github.com/Microsoft/pxt-ev3 2017-12-11 17:08:12 -08:00
1f380ce959 0.0.39 2017-12-11 17:00:06 -08:00
8cbf601131 0.0.38 2017-12-11 17:00:03 -08:00
bdbb2a8c2f Fix on start color 2017-12-11 16:58:29 -08:00
5e90cb4434 Merge pull request #75 from Microsoft/new_ts
Update to latest TS and update blocks colors to match Lego's edu colors
2017-12-11 16:55:25 -08:00
1bf1eb16f0 Update to latest TS and update blocks colors to match Lego's edu colors 2017-12-11 16:55:00 -08:00
fbc6fc30a7 some speed renamings 2017-12-11 16:07:46 -08:00
fee2329ca7 Merge branch 'master' of https://github.com/Microsoft/pxt-ev3 2017-12-08 11:23:07 -08:00
5656031e2d Merge pull request #73 from Microsoft/more_sounds
Limit sound concurrency to 1
2017-12-08 11:21:21 -08:00
e87e1767b5 Null check 2017-12-08 11:16:47 -08:00
2d7a108e79 Fix merge conflict 2017-12-07 16:28:30 -08:00
193f66fd2d Limit sound concurrency to 1 2017-12-07 16:27:28 -08:00
5768fcaf35 Merge branch 'master' of https://github.com/Microsoft/pxt-ev3 2017-12-07 13:58:38 -08:00
2c22ea925f Merge pull request #69 from Microsoft/sounds
Get rid of "play sound" blocks; add non-blocking "play sound effect"
2017-12-07 11:53:04 -08:00
4e4aa266d5 Limit sound concurrency 2017-12-07 11:27:29 -08:00
05bdbd7b40 icon resources 2017-12-07 08:33:13 -08:00
085ab0844b rename "power" to "set speed" for consistency 2017-12-06 22:41:51 -08:00
064d6f9411 Check if sound not defined 2017-12-04 12:24:41 -08:00
330aff8082 Restore 'play sound effect' name 2017-12-01 09:59:59 -08:00
0886a5d4e1 Merge branch 'master' of https://github.com/Microsoft/pxt-ev3 2017-11-30 15:54:11 -08:00
aa636aef96 Separate blocks for 'play sound' and 'play sound until done' 2017-11-30 15:49:50 -08:00
502 changed files with 35037 additions and 6936 deletions

1
.gitignore vendored
View File

@ -16,6 +16,7 @@ clients/win10/*.opendb
clients/**/bin/**
clients/**/obj/**
clients/electron/projects
libs/**/_locales/**
videos/**

View File

@ -2,15 +2,16 @@
[![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
Issue tracker: https://src.education.lego.com/groups/ev3-makecode
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
## Local Dev setup
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/)
@ -57,12 +58,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,16 +1,11 @@
/// <reference path="../node_modules/pxt-core/typings/globals/node/index.d.ts"/>
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
import * as fs from 'fs';
require("./editor")
declare namespace pxt.editor {
function deployCoreAsync(resp: pxtc.CompileResult, disconnect?: boolean): Promise<void>;
}
const deploy = require("./editor/deploy")
export function deployCoreAsync(resp: pxtc.CompileResult) {
return pxt.editor.deployCoreAsync(resp, process.env["PXT_SERIAL"] ? false : true)
return deploy.deployCoreAsync(resp, process.env["PXT_SERIAL"] ? false : true)
.then(() => {
fs.writeFileSync("built/full-" + pxtc.BINARY_UF2, resp.outfiles[pxtc.BINARY_UF2], {
encoding: "base64"

View File

@ -1,4 +1,3 @@
/// <reference path="../node_modules/pxt-core/typings/globals/node/index.d.ts"/>
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
import * as path from "path";

View File

@ -8,6 +8,7 @@
"module": "commonjs",
"rootDir": ".",
"newLine": "LF",
"sourceMap": false
"sourceMap": false,
"types": ["node"]
}
}

View File

@ -1,5 +1,131 @@
# @extends
## Projects #projects
* [Getting Started](/getting-started)
* [Try](/getting-started/try)
* [Use](/getting-started/use)
* [Coding](/coding)
* [Autonomous Parking](/coding/autonomous-parking)
* [Object Detection](/coding/object-detection)
* [Line Following](/coding/line-following)
* [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)
* [Maker](/maker)
* [Make a Sound Machine](/maker/sound-machine)
* [Examples](/examples)
* [Make it move](/lessons/make-it-move)
* [Line detection](/lessons/line-detection)
* [Sound of Color](/maker/sound-of-color)
* [Security Gadget](/maker/security-gadget)
* [Intruder detector](/maker/intruder-detector)
* [Puppet](/maker/puppet)
* [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](/coding/ignition)
* [Cruise Control](/coding/cruise-control)
* [Roaming 1](/coding/roaming-1)
* [Roaming 2](/coding/roaming-2)
## Reference #reference
* [Reference](/reference)
* [Brick](/reference/brick)
* [show string](/reference/brick/show-string)
* [show number](/reference/brick/show-number)
* [show value](/reference/brick/show-value)
* [show mood](/reference/brick/show-mood)
* [show image](/reference/brick/show-image)
* [clear screen](/reference/brick/clear-screen)
* [on event](/reference/brick/button/on-event)
* [is pressed](/reference/brick/button/is-pressed)
* [was pressed](/reference/brick/button/was-pressed)
* [pause until](/reference/brick/button/pause-until)
* [set light](/reference/brick/set-status-light)
* [battery level](/reference/brick/battery-level)
* [Motors](/reference/motors)
* [run](/reference/motors/motor/run)
* [stop](/reference/motors/motor/stop)
* [reset](/reference/motors/motor/reset)
* [set brake](/reference/motors/motor/set-brake)
* [set inverted](/reference/motors/motor/set-inverted)
* [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)
* [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 for color](/reference/sensors/color-sensor/pause-for-color)
* [on light changed](/reference/sensors/color-sensor/on-light-changed)
* [pause for light](/reference/sensors/color-sensor/pause-for-light)
* [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

@ -6,26 +6,26 @@ Welcome to the **Microsoft MakeCode** editor for the **@boardname@**!
You can program the @boardname@ using [Blocks](/blocks) or [JavaScript](/javascript) in your web browser:
```block
input.buttonA.onEvent(ButtonEvent.Click, () => {
light.showRing(`blue blue blue blue blue blue blue blue blue blue`)
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.run(50)
})
```
```typescript
input.buttonA.onEvent(ButtonEvent.Click, () => {
light.showRing(`blue blue blue blue blue blue blue blue blue blue`)
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.run(50)
})
```
The editor work in [most modern browsers](/browsers), work [offline](/offline) once loaded and do not require any installation.
## [Compile and Flash: Your Program!](/device/usb)
## Compile and Flash: Your Program!
When you have your code ready, you connect your @boardname@ to a computer via a USB cable
**then press the reset button** so it appears as a mounted drive (named **CPLAYBOOT**).
so it appears as a mounted drive (named **EV3**).
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 **CPLAYBOOT** drive, which flashes the device with the new program.
program to a **.uf2** file, which you then copy to the **EV3** drive, which flashes the device with the new program.
## Simulator: Test Your Code
@ -33,11 +33,7 @@ You can run your code using the micro:bit simulator, all within the confines of
The simulator has support for the LED screen, buttons, as well as compass, accelerometer, and digital I/O pins.
```sim
loops.forever(() => {
light.pixels.showAnimation(light.animation(LightAnimation.Rainbow), 1000)
brick.buttonEnter.onEvent(ButtonEvent.Bumped, () => {
motors.largeA.run(50)
})
```
```package
light
```

View File

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

27
docs/coding.md Normal file
View File

@ -0,0 +1,27 @@
# Coding Activites
## Projects
```codecard
[
{
"name": "Autonomous Parking",
"description": "Design cars that can park by themselves",
"url":"/coding/autonomous-parking",
"imageUrl": "/static/lessons/autonomous-parking.png",
"cardType": "side"
}, {
"name": "Object Detection",
"description": "TBD",
"url":"/coding/object-detection",
"imageUrl": "/static/lessons/object-detection.jpg",
"cardType": "side"
}, {
"name": "Line Following",
"description": "TBD",
"url":"/coding/line-detection",
"imageUrl": "/static/lessons/line-detection.jpg",
"cardType": "side"
}]
```

View File

@ -0,0 +1,172 @@
# 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 LEGO MINDSTORMS vehicle that can park itself safely without driver intervention.
Start by constructing this [model](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf).
![EV3- Robot Driving Base](/static/coding/autonomous-parking/ev3-robot-driving-base.jpg)
### Checks
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

@ -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()
})
```

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.wasPressed() &&
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.wasPressed() &&
brick.buttonEnter.wasPressed()) {
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
}
pause(1);
}
```

View File

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

View File

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

View File

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

View File

@ -0,0 +1,238 @@
# 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 LEGO MINDSTORMS vehicle that can help prevent drivers from falling asleep and causing an accident.
Start by constructing this [model](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-color-sensor-down-driving-base-d30ed30610c3d6647d56e17bc64cf6e2.pdf):
![EV3 robot with color sensor](/static/coding/line-detection/ev3-robot-color-sensor-down.jpg)
Build red and green “lights” for your robot to detect. You can use LEGO bricks, colored tape, or marker on white paper. Read the building [instructions](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/color%20squares-0a88dfd98bb2e64b5b8151fc422bae36.pdf).
![IMAGE: Color Squares](/static/coding/line-detection/ev3-color-squares.jpg)
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?
![IMAGE: 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.pauseForColor(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.pauseForColor(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.pauseForColor(ColorSensorColor.Red)
motors.stopAll()
sensors.color3.pauseForColor(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.pauseForColor(ColorSensorColor.Black)
music.playSoundEffect(sounds.systemGeneralAlert)
motors.largeBC.steer(30, 20)
sensors.color3.pauseForColor(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) {
}
```
### ~
### Sample Solutions
#### Line Following in Loop
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.pauseForColor(ColorSensorColor.Black)
motors.largeBC.steer(-30, 50)
}
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.White)
motors.largeBC.steer(30, 50)
}
})
```
#### Line Following in Loop
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.pauseForColor(ColorSensorColor.Black)
motors.largeBC.steer(-30, 50)
} else {
sensors.color3.pauseForColor(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 LEGO MINDSTORMS vehicle that can avoid accidents between vehicles and objects in the road.
Start by constructing this [model](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-ultrasonic-sensor-driving-base-61ffdfa461aee2470b8ddbeab16e2070.pdf).
![EV3 Robot Driving Base](/static/coding/object-detection/ev3-robot-driving-base.jpg)
Build an obstacle for your robot to detect. You can build the [cuboid model](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-cuboid-dc93b2e60bed2981e76b3bac9ea04558.pdf) out of LEGO bricks or an obstacle of your choice.
![Cubiod block](/static/coding/object-detection/ev3-cuboid.jpg)
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

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

View File

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

View File

@ -0,0 +1,20 @@
# Reverse Beeper Activity 2
```blocks
let beep = false
beep = true
control.runInParallel(function () {
motors.largeBC.run(-20)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
motors.largeBC.stop()
beep = false
})
control.runInParallel(function () {
while (beep) {
if (sensors.ultrasonic4.distance() < 20) {
music.playTone(440, sensors.ultrasonic4.distance())
pause(50)
}
}
})
```

View File

@ -0,0 +1,14 @@
# Reversing the robot Activity 1
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.run(50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.run(0)
pause(1000)
brick.setStatusLight(StatusLight.OrangeFlash)
motors.largeBC.run(-50)
pause(2000)
motors.largeBC.run(0)
})
```

View File

@ -0,0 +1,15 @@
# Reversing the robot Activity 2
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.run(50)
sensors.touch2.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.run(0)
pause(1000)
brick.setStatusLight(StatusLight.OrangeFlash)
motors.largeBC.run(-50)
pause(2000)
motors.largeBC.run(0)
})
```

View File

@ -0,0 +1,19 @@
# Reversing the robot Activity 3
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showImage(images.eyesSleeping)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
brick.showImage(images.eyesNeutral)
motors.largeBC.run(50)
sensors.touch2.pauseUntil(ButtonEvent.Pressed)
brick.showImage(images.eyesTiredMiddle)
motors.largeBC.run(0)
pause(1000)
brick.setStatusLight(StatusLight.OrangeFlash)
brick.showImage(images.eyesDizzy)
motors.largeBC.run(-50)
pause(2000)
motors.largeBC.run(0)
})
```

32
docs/coding/roaming-1.md Normal file
View File

@ -0,0 +1,32 @@
# Roaming Activity 1
```blocks
let drive: number[] = []
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function () {
drive.push(1)
})
brick.buttonRight.onEvent(ButtonEvent.Bumped, function () {
drive.push(3)
})
brick.buttonUp.onEvent(ButtonEvent.Bumped, function () {
drive.push(4)
})
brick.buttonDown.onEvent(ButtonEvent.Bumped, function () {
drive.push(5)
})
pauseUntil(() => drive.length >= 5)
pause(1000)
music.playSoundEffectUntilDone(sounds.communicationGo)
for (let d of drive) {
if (d == 1) {
motors.largeC.run(50, 360, MoveUnit.Degrees)
} else if (d == 3) {
motors.largeB.run(50, 360, MoveUnit.Degrees)
} else if (d == 4) {
motors.largeBC.run(50, 360, MoveUnit.Degrees)
} else {
motors.largeBC.run(-50, 360, MoveUnit.Degrees)
}
}
music.playSoundEffectUntilDone(sounds.communicationGameOver)
```

36
docs/coding/roaming-2.md Normal file
View File

@ -0,0 +1,36 @@
# Roaming Activity 2
```blocks
let drive: number[] = []
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function () {
drive.push(1)
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonRight.onEvent(ButtonEvent.Bumped, function () {
drive.push(3)
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonUp.onEvent(ButtonEvent.Bumped, function () {
drive.push(4)
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonDown.onEvent(ButtonEvent.Bumped, function () {
drive.push(5)
music.playSoundEffectUntilDone(sounds.systemClick)
})
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
pause(1000)
music.playSoundEffectUntilDone(sounds.communicationGo)
for (let d of drive) {
if (d == 1) {
motors.largeC.run(50, 360, MoveUnit.Degrees)
} else if (d == 3) {
motors.largeB.run(50, 360, MoveUnit.Degrees)
} else if (d == 4) {
motors.largeBC.run(50, 360, MoveUnit.Degrees)
} else {
motors.largeBC.run(-50, 360, MoveUnit.Degrees)
}
}
music.playSoundEffectUntilDone(sounds.communicationGameOver)
```

View File

@ -0,0 +1,12 @@
# Three Point Turn Activity 1
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(75, 30)
pause(1500)
motors.largeBC.tank(-30, -75)
pause(1000)
motors.largeBC.tank(50, 50)
pause(3000)
})
```

View File

@ -0,0 +1,14 @@
# Three Point Turn Activity 2
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(75, 30)
pause(1500)
motors.largeBC.tank(-30, -75)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear);
motors.largeBC.tank(0, 0)
pause(1000)
motors.largeBC.tank(50, 50)
pause(3000)
})
```

View File

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

View File

@ -0,0 +1,9 @@
# Traffic Lights Activity 1
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
motors.largeBC.tank(20, 20)
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.largeBC.tank(0, 0)
})
```

View File

@ -0,0 +1,10 @@
# Traffic Lights Activity 2
```blocks
sensors.color3.onColorDetected(ColorSensorColor.Red, function () {
motors.largeBC.tank(0, 0)
})
sensors.color3.onColorDetected(ColorSensorColor.Green, function () {
motors.largeBC.tank(20, 20)
})
```

View File

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

View File

@ -0,0 +1,29 @@
# Design Engineering Projects
## Projects
```codecard
[
{
"name": "Make It Move Without Wheels",
"description": "TBD",
"imageUrl": "/static/lessons/make-it-move-without-wheels.png",
"url": "/design-engineering/make-it-move",
"cardType": "side"
},
{
"name": "Make It Smarter and Faster",
"description": "TBD",
"imageUrl": "/static/lessons/make-it-smarter-and-faster.png",
"url": "/design-engineering/make-it-smarter",
"cardType": "side"
},
{
"name": "Make a System that Communicates",
"description": "A robot that tells you what it is doing.",
"imageUrl": "/static/lessons/make-a-system-that-communicates.png",
"url": "/design-engineering/make-it-communicate",
"cardType": "side"
}
]
```

View File

@ -0,0 +1,164 @@
# 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/hero.png)
## Construct
### Build
You can start by tinkering with the LEGO elements in the picture and then build on.
More building ideas:
* [EV3 Frames](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/ev3%20frames-5054ee378e624fb4cb31158d2fc8e5cf.pdf)
* [Tracks](https://le-www-live-s.legocdn.com/sc/media/files/support/mindstorms%20ev3/building-instructions/design%20engineering%20projects/tracks-32d7554813af3f25cf5012d54a4bad2b.pdf)
* [Color Sensor 2](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/trackrover.mp4)
The Track Rover follows a path using the color sensor. It identifies two locations by color.
[Building Instructions](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)
} else {
}
})
```
```blocks
sensors.color3.onColorDetected(ColorSensorColor.Black, function () {
motors.largeB.run(-50)
motors.largeC.run(0)
})
sensors.color3.onColorDetected(ColorSensorColor.White, function () {
motors.largeB.run(0)
motors.largeC.run(-50)
})
sensors.color3.onColorDetected(ColorSensorColor.Green, function () {
motors.stopAll()
music.playSoundEffect(sounds.colorsGreen)
pause(1000)
motors.largeBC.run(-50)
})
sensors.color3.onColorDetected(ColorSensorColor.Red, function () {
motors.stopAll()
music.playSoundEffect(sounds.colorsRed)
pause(1000)
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,90 @@
# Make It Move Without Wheels
## ~ avatar
Design, build and program a robot that can move itself using no wheels for locomotion.
## ~
## Connect
### Design Brief
Design, build and program a robot that can move itself a distance of at least 30cm, using at least one motor, using NO wheels for locomotion.
### Brainstorm
Discuss different solutions to the design brief.
Think about:
How can robots move without wheels? For example, how will you:
* Connect the motor(s) to something to make the robot walk, crawl, or wiggle?
How will you program the robot to move? For example, which programming blocks will you use to:
* Turn on and turn off the motor or motors?
* Display the distance moved?
### Select the Best Solution
Describe the solution that you have agreed to build and program.
Think about examples from your brainstorming discussion. Then explain why you chose this solution for the design brief.
![The Mars rover](/static/lessons/make-it-move/hero.png)
https://www.youtube.com/ErC_s3hLGMk
## Construct
### Build and Program
Now you are ready to start building and programming your solution!
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations);
motors.stopAll();
```
As you work on your solution:
* Describe one part of your design that worked especially well.
* Describe one design change that you had to make.
What will you try next?
As you test your design solution, use the table for recording your findings.
[**VIEW BUILDING INSTRUCTIONS**](TODO) for a sample solution. (7.8 MB, PDF)
## Contemplate
### Test and Analyze
How well does your solution satisfy the design brief? Record your data. Name the columns and rows, such as Trial Number, Distance Moved, and Observations.
### Review and Revise
Take a moment to reflect on your robot solution.
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?
Describe two ways you could improve your robot.
## Continue
### 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!
## ~ avatar
Congratulations! What will you design next?
## ~

View File

@ -0,0 +1,192 @@
# 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](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)
### 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
### ~
## SCREEN 5
Sample Solution
[Video: EV3 Insect]
This Insect uses its Ultrasonic Sensor to sense danger and move away from threat.
The Insect solution combines these building ideas:
* EV3 Frames
* Leg 2
* Leg 3
* Ultrasonic Sensor
Four copies of Leg 3 were built: one for the front left, one for the back right, and two mirror copies for the front right and back left.
* [Building Instructions](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.
This program:
* Turns on the green EV3 brick Status Light
```block
brick.setStatusLight(StatusLight.Green)
```
* Waits for Ultrasonic Sensor to detect an object
```block
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectDetected)
```
* Turns on Motors A and D in opposite directions
```block
motors.largeAD.tank(50, -50)
```
* Waits for one half of a second (1500 milli seconds)
```block
pause(1500)
```
* Reverses the direction of Motors A and D
```block
motors.largeAD.tank(-50, 50)
```
* Waits for one half of a second
* Stops all motors
```block
motors.stopAll()
```
* Makes an insect chirping sound
```block
music.playSoundEffectUntilDone(sounds.animalsInsectChirp)
```
* Loops so the insect wanders around when the Ultrasonic Sensor is triggered
```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? Add arts and crafts materials to you 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?

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": "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"
}
]
```
## 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

@ -0,0 +1,178 @@
# Gyroboy
Work in progress
```blocks
let motorSpeed1 = 0
let motorSpeed2 = 0
let motorSpeed3 = 0
let motorSpeed = 0
let fallen = false
let motorSpeed0 = 0
let oldControlDrive = 0
let controlDrive = 0
let power = 0
let motorAngle = 0
let gyroAngle = 0
let controlSteering = 0
let state = 0
let motorPosition = 0
let temp = 0
let gyroRate = 0
let timestep = 0
sensors.color1.onColorDetected(ColorSensorColor.Red, function () {
music.playTone(2000, 100)
controlDrive = 0
controlSteering = 0
})
// reads the motor angle and computes the motor speed,
// position
function computeMotors() {
temp = motorAngle
// read angle on both motors
motorAngle = motors.largeD.angle() + motors.largeA.angle()
// and estimate speed as angle difference
motorSpeed0 = motorAngle - temp
// average last 4 speed readings
motorSpeed = (motorSpeed0 + motorSpeed1 + motorSpeed2 + motorSpeed3) / 4 / timestep
// shift all previous recorded speeds by one
motorSpeed3 = motorSpeed2
motorSpeed2 = motorSpeed1
motorSpeed1 = motorSpeed0
// compute position from speed
motorPosition = motorPosition + timestep * motorSpeed
}
// read the gyro rate and computes the angle
function computeGyro() {
gyroRate = sensors.gyro2.rate()
gyroAngle = gyroAngle + timestep * gyroRate
}
function reset() {
state = 0
// sleeping
moods.sleeping.show();
// reset counters
motors.largeA.reset()
motors.largeD.reset()
// motors are unregulated
motors.largeA.setRegulated(false)
motors.largeD.setRegulated(false)
// clear the gyro sensor to remove drift
sensors.gyro2.reset()
// fall detection timer
control.timer2.reset()
// timestep computation timer
control.timer3.reset()
motorAngle = 0
motorPosition = 0
motorSpeed = 0
motorSpeed0 = 0
motorSpeed1 = 0
motorSpeed2 = 0
motorSpeed3 = 0
gyroRate = 0
gyroAngle = 0
fallen = false
power = 0
controlSteering = 0
controlDrive = 0
// awake
moods.awake.show();
gyroAngle = -0.25
state = 1;
}
// compute set point for motor position and required
// motor power
function computePower() {
// apply control and compute desired motor position
motorPosition -= timestep * controlDrive;
// estimate power based on sensor readings and control
// values
power = 0.8 * gyroRate + 15 * gyroAngle + (0.08 * motorSpeed + 0.12 * motorPosition) - 0.01 * controlDrive
// ensure that power stays within -100, 100
if (power > 100) {
power = 100
} else if (power < -100) {
power = -100
}
}
// test if the robot has fallen off
function checkFallen() {
if (Math.abs(power) < 100) {
control.timer2.reset()
}
if (control.timer2.seconds() > 2) {
fallen = true
}
}
// stop all motors and wait for touch button to be
// pressed
function stop() {
motors.stopAll()
state = 0
moods.knockedOut.show();
sensors.touch3.pauseUntil(ButtonEvent.Pressed)
moods.neutral.show();
}
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () {
moods.dizzy.show()
controlSteering = 0
oldControlDrive = controlDrive
controlDrive = -10
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
}
pause(4000)
music.playTone(2000, 100)
controlSteering = 0
controlDrive = oldControlDrive
moods.neutral.show()
})
// compute the elapsed time since the last iteration
function computeTimestep() {
timestep = control.timer3.seconds()
control.timer3.reset()
}
sensors.color1.onColorDetected(ColorSensorColor.Green, function () {
moods.winking.show()
controlDrive = 150
controlSteering = 0
})
sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {
moods.middleRight.show()
controlSteering = 70
})
// apply power to motors
function controlMotors() {
motors.largeA.run(power + controlSteering * 0.1)
motors.largeD.run(power - controlSteering * 0.1)
}
sensors.color1.onColorDetected(ColorSensorColor.Yellow, function () {
moods.middleLeft.show()
controlSteering = -70
})
sensors.color1.onColorDetected(ColorSensorColor.White, function () {
moods.sad.show();
controlDrive = -75
})
timestep = 0.014
// main loop
forever(function () {
reset()
while (!fallen) {
control.timer3.pauseUntil(5)
computeTimestep()
computeGyro()
computeMotors()
computePower()
controlMotors()
checkFallen()
}
stop()
})
```

View File

@ -0,0 +1,215 @@
# Gyroboy LabView
```typescript
let mSum = 0;
let mPos = 0;
let mSpd = 0;
let mD = 0;
let mDP1 = 0;
let mDP2 = 0;
let mDP3 = 0;
let Crdv = 0;
let cLo = 0;
let gAng = 0;
let ok = false;
let pwr = 0;
let Cstr = 0;
let Cdrv = 0;
let gMn = 0;
let gMx = 0;
let gSum = 0;
let gyro = 0;
let gOS = 0;
let gSpd = 0;
let tInt = 0.014;
let lpwr = 0
let rpwr = 0
let tStart = 0
let st = 0
let oldDr = 0
function RST() {
motors.largeA.reset()
motors.largeD.reset()
motors.largeA.setRegulated(false)
motors.largeD.setRegulated(false)
sensors.gyro2.reset()
sensors.gyro2.rate()
control.timer2.reset()
pause(5000)
mSum = 0;
mPos = 0;
mD = 0;
mDP1 = 0;
mDP2 = 0;
mDP3 = 0;
Crdv = 0;
cLo = 0;
gAng = 0;
ok = false;
pwr = 0;
st = 0;
Cstr = 0;
Cdrv = 0;
}
function OS() {
// OSL
do {
gMn = 1000;
gMx = -100;
gSum = 0;
// gChk
for (let i = 0; i < 200; i++) {
gyro = sensors.gyro2.rate()
gSum = gyro;
gMx = Math.max(gMx, gyro)
gMn = Math.min(gMn, gyro)
pause(4);
}
} while (gMx - gMn > 2);
gOS = gSum / 200;
}
function GT() {
if (cLo == 0) {
tInt = 0.014;
control.timer1.reset();
} else {
tInt = control.timer1.seconds() / cLo;
}
cLo++;
}
function GG() {
gyro = sensors.gyro2.rate();
gOS = 0.0005 * gyro + (1 - 0.0005) * gOS
gSpd = gyro - gOS;
gAng = gAng + tInt * gSpd;
}
function GM() {
let temp = mSum
mSum = motors.largeD.angle() + motors.largeA.angle();
mD = mSum - temp;
mPos = mPos + mD;
mSpd = ((mDP1 + mDP2 + mDP3 + mD) / 4) / tInt;
mDP3 = mDP2;
mDP2 = mDP1;
mDP1 = mD;
}
function EQ() {
mPos = mPos - Cdrv * tInt;
pwr = (0.8 * gSpd + 15 * gAng) + (0.08 * mSpd + 0.12 * mPos) - 0.01 * Cdrv
if (pwr > 100) pwr = 100
else if (pwr < -100) pwr = -100
}
function cntrl() {
mPos = mPos - tInt * Cdrv
lpwr = (pwr + Cstr * 0.1)
rpwr = (pwr - Cstr * 0.1)
}
function CHK() {
if (Math.abs(pwr) < 100)
control.timer2.reset();
if (control.timer2.seconds() > 2) {
ok = true;
}
}
// M
forever(function () {
RST();
brick.showImage(images.eyesSleeping)
OS()
gAng = -0.25;
music.playSoundEffect(sounds.movementsSpeedUp)
brick.showImage(images.eyesAwake)
st = 1;
// BALANCE
while (!ok) {
GT();
let t1 = control.timer1.millis()
GG();
GM();
EQ();
cntrl();
motors.largeA.run(lpwr)
motors.largeD.run(rpwr)
CHK()
let t2 = control.timer1.millis();
let p = 5 - (t2 - t1);
pause(Math.max(1, p))
}
motors.stopAll()
st = 0;
brick.setStatusLight(StatusLight.RedPulse);
brick.showImage(images.eyesKnockedOut)
music.playSoundEffect(sounds.movementsSpeedDown)
sensors.touch3.pauseUntil(ButtonEvent.Pressed)
brick.setStatusLight(StatusLight.Off);
})
// BHV
forever(function () {
switch (st) {
case 0:
Cdrv = 0;
Cstr = 0;
break;
case 1:
Cdrv = 40;
pause(4000);
Cdrv = 0;
music.playTone(1000, 100);
st = 2;
break;
case 2:
switch (sensors.color1.color()) {
case ColorSensorColor.Red:
music.playTone(2000, 100);
Cdrv = 0;
Cstr = 0;
break;
case ColorSensorColor.Green:
music.playTone(2000, 100);
Cdrv = 150;
Cstr = 0;
break;
case ColorSensorColor.Blue:
music.playTone(2000, 100);
Cstr = 70;
break;
case ColorSensorColor.Yellow:
music.playTone(2000, 100);
Cstr = -70;
break;
case ColorSensorColor.White:
music.playTone(2000, 100);
Cdrv = -75;
break;
}
if (sensors.ultrasonic4.distance() < 25) {
Cstr = 0;
oldDr = Cdrv;
Cdrv = -10;
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;
pause(4000);
music.playTone(2000, 100)
Cstr = 0;
Cdrv = oldDr;
}
break;
}
pause(80);
})
```

View File

@ -0,0 +1,390 @@
# Puppy
```typescript
let P_T = 0;
let ISS = 0;
let F_T = 0;
let P_C = 0;
let F_C = 0;
let DB_S = 0;
let NS = false;
let IBP = 0;
let IAP = 0;
let C = false;
let TC = false;
let OTC = false;
let COL = 0;
let OCOL = 0;
let _C = false;
let GTO = 0;
function DN() {
motors.largeAD.setBrake(true);
motors.largeAD.tank(50, 50, 1, MoveUnit.Seconds);
pause(100);
motors.largeA.clearCounts()
motors.largeD.clearCounts()
}
function MNRH() {
motors.mediumC.setBrake(true)
brick.showImage(images.legoEv3icon)
brick.setStatusLight(StatusLight.OrangePulse)
while (!brick.buttonEnter.wasPressed()) {
if (brick.buttonUp.wasPressed()) {
motors.mediumC.run(-100);
} else if (brick.buttonDown.wasPressed()) {
motors.mediumC.run(100);
} else {
motors.mediumC.stop();
}
}
motors.mediumC.stop();
motors.mediumC.clearCounts();
brick.setStatusLight(StatusLight.Green);
}
function IS(t: number) {
ISS = t;
switch (t) {
case 0:
brick.showImage(images.eyesNeutral);
break;
case 1:
brick.showImage(images.eyesSleeping);
break;
case 2:
brick.showImage(images.eyesTear);
// draw rect...
break;
case 3:
brick.showImage(images.eyesHurt);
break;
case 4:
brick.showImage(images.eyesAngry);
break;
case 5:
brick.showImage(images.eyesTiredMiddle);
break;
case 6:
brick.showImage(images.eyesTiredRight);
break;
case 7:
brick.showImage(images.eyesTiredLeft);
break;
case 8:
brick.showImage(images.eyesLove);
break;
}
}
function UP() {
if (motors.largeA.angle() > -50) {
control.runInParallel(function () {
motors.largeD.clearCounts()
motors.largeD.run(-35);
pauseUntil(() => motors.largeD.angle() < -25);
motors.largeD.stop();
motors.largeD.setRegulated(false)
motors.largeD.run(-15)
pauseUntil(() => motors.largeD.angle() < -65);
motors.largeD.stop();
})
motors.largeA.clearCounts()
motors.largeA.run(-35);
pauseUntil(() => motors.largeA.angle() < -25);
motors.largeA.stop();
motors.largeA.setRegulated(false)
motors.largeA.run(-15)
pauseUntil(() => motors.largeA.angle() < -65);
motors.largeA.stop();
pause(500);
}
}
function RST() {
P_T = Math.randomRange(3, 6);
F_T = Math.randomRange(2, 4);
P_C = 1;
F_C = 1;
control.timer1.reset();
control.timer2.reset();
control.timer3.reset();
CS(0);
}
function CS(db: number) {
if (DB_S != db) {
DB_S = db;
NS = true;
}
}
function MON() {
if (control.timer2.seconds() > 10) {
control.timer2.reset();
P_C--;
if (P_C < 0) {
P_C = 0;
}
}
if (control.timer1.seconds() > 20) {
control.timer1.reset()
F_C--;
if (F_C < 0) {
F_C = 0;
}
}
if (control.timer3.seconds() > 30) {
control.timer3.reset();
CS(1);
}
}
function UIS() {
if (control.timer5.seconds() > IBP) {
control.timer5.reset();
if (ISS == 1) {
ISS = 6;
IBP = Math.randomRange(1, 5);
} else {
ISS = 1;
IBP = 0.25;
}
IS(ISS);
}
if (control.timer6.seconds() > IAP) {
if (ISS != 1) {
control.timer6.reset();
IAP = Math.randomRange(1, 10)
if (ISS != 7) {
ISS = 7
} else {
ISS = 6;
}
IS(ISS);
}
}
}
function UPDB() {
if ((P_T == P_C) && (F_T == F_C)) {
CS(6);
}
if ((P_T > P_C) && (F_T < F_C)) {
CS(3);
}
if ((P_T < P_C) && (F_T > F_C)) {
CS(5);
}
if ((P_C == 0) && (F_C > 0)) {
CS(2)
}
if (F_C == 0) {
CS(4)
}
}
function PTC() {
C = false;
OTC = TC;
TC = sensors.touch1.isPressed()
if (TC != OTC && TC) {
P_C++;
control.timer3.reset();
if (DB_S != 4) {
IS(2);
music.playSoundEffect(sounds.animalsDogSniff);
C = true;
}
}
return C;
}
function FDC() {
OCOL = COL;
COL = sensors.color4.color();
_C = false;
if ((COL != 0) && (OCOL != COL)) {
F_C++;
_C = true;
control.timer3.reset();
IS(2);
music.playSoundEffect(sounds.expressionsCrunching)
}
return _C;
}
function IDL() {
if (NS) {
NS = false;
UP();
}
UIS();
UPDB();
PTC();
FDC();
}
function MHT(Pos: number) {
let _R = Pos - motors.mediumC.angle();
if (_R >= 0) {
motors.mediumC.run(100, _R, MoveUnit.Degrees);
} else {
motors.mediumC.run(-100, Math.abs(_R), MoveUnit.Degrees);
}
}
function SLP() {
if (NS) {
NS = false;
IS(5)
DN()
MHT(3000)
IS(1)
music.playSoundEffect(sounds.expressionsSnoring)
}
if (sensors.touch1.isPressed() || brick.buttonEnter.isPressed()) {
music.stopAllSounds();
control.timer3.reset();
CS(7);
}
}
function PLF() {
if (NS) {
NS = false
IS(0)
UP()
music.playSoundEffect(sounds.animalsDogBark2)
control.timer4.reset()
GTO = Math.randomRange(4, 8);
}
if(PTC()) {
CS(0);
}
if (control.timer4.seconds() > GTO) {
music.playSoundEffect(sounds.animalsDogBark2)
control.timer4.reset();
GTO = Math.randomRange(4, 8);
}
}
function NGR() {
NS = false
IS(4)
music.playSoundEffect(sounds.animalsDogGrowl);
UP();
pause(1500);
music.stopAllSounds()
music.playSoundEffect(sounds.animalsDogBark1)
P_C--;
CS(0);
}
function HNG() {
if (NS) {
NS = false;
IS(3)
DN();
music.playSoundEffect(sounds.animalsDogWhine);
}
if(FDC()) {
CS(0)
}
if (PTC()) {
CS(3);
}
}
function PPP() {
NS = false;
IS(2);
UP();
pause(100)
motors.largeA.run(-30, 70, MoveUnit.Degrees);
pause(800);
music.playSoundEffect(sounds.mechanicalHorn1);
pause(1000);
for(let i = 0; i < 3; ++i) {
motors.largeA.run(-30, 20, MoveUnit.Degrees);
motors.largeA.run(30, 20, MoveUnit.Degrees);
}
motors.largeA.run(30, 70, MoveUnit.Degrees);
F_C = 1;
CS(0);
}
function HPY() {
IS(8)
MHT(0);
motors.largeAD.run(10, 0.8, MoveUnit.Seconds);
for(let i = 0; i < 3; ++i) {
music.playSoundEffect(sounds.animalsDogBark1);
motors.largeAD.run(-100, 0.2, MoveUnit.Seconds);
pause(300)
motors.largeAD.run(10, 0.3, MoveUnit.Seconds)
}
pause(500);
music.stopAllSounds();
DN();
RST();
}
function STL() {
UP();
motors.largeAD.run(-20, 60, MoveUnit.Degrees);
music.playSoundEffect(sounds.animalsDogWhine);
motors.largeAD.run(20, 60, MoveUnit.Degrees);
}
function WKU() {
let stateC = false;
IS(5);
music.playSoundEffect(sounds.animalsDogWhine)
MHT(0)
DN()
STL()
pause(1000);
UP()
CS(0;)
}
DN();
MNRH();
// compare button state???
IS(1);
UP();
RST();
forever(function () {
MON();
switch (DB_S) {
case 0:
IDL();
break;
case 1:
SLP();
break;
case 2:
PLF();
break;
case 3:
NGR();
break;
case 4:
HNG();
break;
case 5:
PPP();
break;
case 6:
HPY();
break;
case 7:
WKU();
break;
}
})
```

View File

@ -0,0 +1,51 @@
# Robot Arm
```typescript
function INI() {
motors.largeB.setBrake(true)
motors.largeC.setBrake(true)
motors.mediumA.setBrake(true)
motors.largeB.run(-50)
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop();
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.run(-50, 0.86, MoveUnit.Rotations);
}
INI()
let down = false;
forever(function () {
brick.showImage(images.informationQuestionMark)
brick.setStatusLight(StatusLight.OrangePulse);
pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed())
brick.setStatusLight(StatusLight.Off)
music.playSoundEffect(sounds.mechanicalAirRelease)
brick.showImage(images.informationAccept)
if (down) {
brick.showImage(images.informationForward)
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
} else {
brick.showImage(images.informationBackward)
motors.largeC.run(-65, 0.85, MoveUnit.Rotations);
}
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.run(-65, 0.86, MoveUnit.Rotations);
} else {
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
}
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,51 @@
# Crane LabView
```blocks
function INI() {
motors.largeB.setBrake(true)
motors.largeC.setBrake(true)
motors.mediumA.setBrake(true)
motors.largeB.run(-50)
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop();
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.run(-50, 0.86, MoveUnit.Rotations);
}
INI()
let down = false;
forever(function () {
brick.showImage(images.informationQuestionMark)
brick.setStatusLight(StatusLight.OrangePulse);
pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed())
brick.setStatusLight(StatusLight.Off)
music.playSoundEffect(sounds.mechanicalAirRelease)
brick.showImage(images.informationAccept)
if (down) {
brick.showImage(images.informationForward)
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
} else {
brick.showImage(images.informationBackward)
motors.largeC.run(-65, 0.85, MoveUnit.Rotations);
}
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.run(-65, 0.86, MoveUnit.Rotations);
} else {
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
}
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

@ -0,0 +1,215 @@
# Gyro Boy LabView
```blocks
let mSum = 0;
let mPos = 0;
let mSpd = 0;
let mD = 0;
let mDP1 = 0;
let mDP2 = 0;
let mDP3 = 0;
let Crdv = 0;
let cLo = 0;
let gAng = 0;
let ok = false;
let pwr = 0;
let Cstr = 0;
let Cdrv = 0;
let gMn = 0;
let gMx = 0;
let gSum = 0;
let gyro = 0;
let gOS = 0;
let gSpd = 0;
let tInt = 0.014;
let lpwr = 0
let rpwr = 0
let tStart = 0
let st = 0
let oldDr = 0
function RST() {
motors.largeA.reset()
motors.largeD.reset()
motors.largeA.setRegulated(false)
motors.largeD.setRegulated(false)
sensors.gyro2.reset()
sensors.gyro2.rate()
control.timer2.reset()
pause(5000)
mSum = 0;
mPos = 0;
mD = 0;
mDP1 = 0;
mDP2 = 0;
mDP3 = 0;
Crdv = 0;
cLo = 0;
gAng = 0;
ok = false;
pwr = 0;
st = 0;
Cstr = 0;
Cdrv = 0;
}
function OS() {
// OSL
do {
gMn = 1000;
gMx = -100;
gSum = 0;
// gChk
for (let i = 0; i < 200; i++) {
gyro = sensors.gyro2.rate()
gSum = gyro;
gMx = Math.max(gMx, gyro)
gMn = Math.min(gMn, gyro)
pause(4);
}
} while (gMx - gMn > 2);
gOS = gSum / 200;
}
function GT() {
if (cLo == 0) {
tInt = 0.014;
control.timer1.reset();
} else {
tInt = control.timer1.seconds() / cLo;
}
cLo++;
}
function GG() {
gyro = sensors.gyro2.rate();
gOS = 0.0005 * gyro + (1 - 0.0005) * gOS
gSpd = gyro - gOS;
gAng = gAng + tInt * gSpd;
}
function GM() {
let temp = mSum
mSum = motors.largeD.angle() + motors.largeA.angle();
mD = mSum - temp;
mPos = mPos + mD;
mSpd = ((mDP1 + mDP2 + mDP3 + mD) / 4) / tInt;
mDP3 = mDP2;
mDP2 = mDP1;
mDP1 = mD;
}
function EQ() {
mPos = mPos - Cdrv * tInt;
pwr = (0.8 * gSpd + 15 * gAng) + (0.095 * mSpd + 0.13 * mPos) - 0.01 * Cdrv
if (pwr > 100) pwr = 100
else if (pwr < -100) pwr = -100
}
function cntrl() {
mPos = mPos - tInt * Cdrv
lpwr = (pwr + Cstr * 0.1)
rpwr = (pwr - Cstr * 0.1)
}
function CHK() {
if (Math.abs(pwr) < 100)
control.timer2.reset();
if (control.timer2.seconds() > 2) {
ok = true;
}
}
// M
forever(function () {
RST();
brick.showImage(images.eyesSleeping)
OS()
gAng = -0.25;
music.playSoundEffect(sounds.movementsSpeedUp)
brick.showImage(images.eyesAwake)
st = 1;
// BALANCE
while (!ok) {
GT();
let t1 = control.timer1.millis()
GG();
GM();
EQ();
cntrl();
motors.largeA.run(lpwr)
motors.largeD.run(rpwr)
CHK()
let t2 = control.timer1.millis();
let p = 5 - (t2 - t1);
pause(Math.max(1, p))
}
motors.stopAll()
st = 0;
brick.setStatusLight(StatusLight.RedPulse);
brick.showImage(images.eyesKnockedOut)
music.playSoundEffect(sounds.movementsSpeedDown)
sensors.touch3.pauseUntil(ButtonEvent.Pressed)
brick.setStatusLight(StatusLight.Off);
})
// BHV
forever(function () {
switch (st) {
case 0:
Cdrv = 0;
Cstr = 0;
break;
case 1:
Cdrv = 40;
pause(4000);
Cdrv = 0;
music.playTone(1000, 100);
st = 2;
break;
case 2:
switch (sensors.color1.color()) {
case ColorSensorColor.Red:
music.playTone(2000, 100);
Cdrv = 0;
Cstr = 0;
break;
case ColorSensorColor.Green:
music.playTone(2000, 100);
Cdrv = 150;
Cstr = 0;
break;
case ColorSensorColor.Blue:
music.playTone(2000, 100);
Cstr = 70;
break;
case ColorSensorColor.Yellow:
music.playTone(2000, 100);
Cstr = -70;
break;
case ColorSensorColor.White:
music.playTone(2000, 100);
Cdrv = -75;
break;
}
if (sensors.ultrasonic4.distance() < 25) {
Cstr = 0;
oldDr = Cdrv;
Cdrv = -10;
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;
pause(4000);
music.playTone(2000, 100)
Cstr = 0;
Cdrv = oldDr;
}
break;
}
pause(80);
})
```

View File

@ -3,10 +3,10 @@
Use a touch sensor to make the brick happy.
```blocks
sensors.touchSensor1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
sensors.touchSensor1.onEvent(TouchSensorEvent.Released, function () {
sensors.touch1.onEvent(ButtonEvent.Released, function () {
brick.showImage(images.expressionsSick)
})
```

View File

@ -0,0 +1,50 @@
# Gradien follower PID + calibration
```blocks
let lasterror = 0
let D = 0
let I = 0
let P = 0
let error = 0
let setpoint = 0
let max = 0
let min = 0
let v = 0
v = sensors.color3.light(LightIntensityMode.Reflected)
min = v
max = v
setpoint = v
while (!(brick.buttonEnter.wasPressed())) {
brick.clearScreen()
brick.showString("Move robot on terrain", 1)
brick.showString("Press ENTER when done", 2)
v = sensors.color3.light(LightIntensityMode.Reflected)
min = Math.min(min, v)
max = Math.max(max, v)
setpoint = (max + min) / 2
brick.showValue("v", v, 3)
brick.showValue("min", min, 4)
brick.showValue("max", v, 5)
brick.showValue("setpoint", setpoint, 6)
pause(100)
}
forever(function () {
brick.clearScreen()
v = sensors.color3.light(LightIntensityMode.Reflected)
brick.showValue("light", v, 1)
error = v - setpoint
brick.showValue("error", error, 2)
P = error * 5
brick.showValue("P", P, 3)
I = I + error * 0.01
brick.showValue("I", I, 4)
D = (error - lasterror) * 0.2
brick.showValue("D", D, 5)
motors.largeBC.steer(P + (I + D), 100)
lasterror = error
if (brick.buttonEnter.wasPressed()) {
motors.largeBC.run(0)
brick.buttonDown.pauseUntil(ButtonEvent.Bumped)
}
})
```

View File

@ -0,0 +1,40 @@
# 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)
}
}
```

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

@ -0,0 +1,22 @@
# Getting Started
## Projects
```codecard
[
{
"name": "Try",
"imageUrl": "/static/lessons/try.png",
"description": "Get a quick introduction to programming with EV3.",
"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"
}
]
```

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

@ -0,0 +1,178 @@
# Try
[IMG: Neutral Image Display on EV3 Brick with Music Notes]
Get a quick introduction to programming with EV3.
We are excited to help you get started with LEGO MINDSTORMS Education EV3. 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
[IMG: Hand pressing power button, Neutral Image Display, EV3 Brick]
Power on your EV3 Brick by pressing the Center Button.
## Connect Your EV3 Brick to Your Device
[IMG: Hand on cable & computer, Neutral Image Display, EV3 Brick]
Use the USB cable to connect your EV3 Brick to your device.
## Create and Run your First Program
[IMG: Try Program Blocks (see JavaScript below)]
1 - Create the program shown here:
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
brick.showMood(moods.neutral)
music.playSoundEffect(sounds.communicationHello)
})
```
* Drag a Brick Screen show mood block inside the on button block
* Change mood to
```block
brick.showMood(moods.neutral)
```
* Drag a Music play sound effect block below the show mood block
* Change sound effect to
```block
music.playSoundEffect(sounds.communicationHello)
```
2 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.
## ~ hint
Note: Click here for help and more information about the programming blocks.
## ~
## Did It Work?
[IMG: Neutral Image Display, EV3 Brick]
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
[IMG: EV3 Brick with hands connecting Large Motor to Port D]
Now you will learn to control the Large Motor.
Connect a Large Motor to Port D of your EV3 Brick using any of the connector cables.
## Create and Run This Program
[IMG: Program Blocks (see JavaScript below)]
1) 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 run large A motor block inside the on button block
* Change large A to large D motors.largeD.run(50)
* Click on the + sign
* Change to 1 rotation
2) 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?
[IMG: Large Motor D w/Rotating “WHRRR,” Hand, EV3 Brick]
Confirm that your motor has turned one rotation at power level 50 before stopping.
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
[IMG: Hands connecting Touch Sensor to Port 1 on EV3 Brick]
We will now control the Large Motor using a Touch Sensor.
Keeping the Large Motor connected to **Port D**, connect a Touch Sensor to **Port 1** of your EV3 Brick.
## Modify Your Program
[IMG: Program Blocks (see JavaScript below)]
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeD.run(50, 1, MoveUnit.Rotations)
})
```
1) Add a pause until touch 1 pressed Sensor block on top of the run large D Motor block
```block
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
```
2) 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
[IMG: Hand Touch Sensor Pressed & EV3 Brick & Large Motor]
Confirm that the Large Motor has turned one rotation AFTER you press the Touch Sensor.
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
[IMG: Hand connecting Color Sensor to Port 4, Large Motor D, EV3 Brick]
Now we will try to control the Large Motor using another sensor.
Keeping the Large Motor connected to **Port D**, connect the Color Sensor to **Port 4**.
Modify Your Program
[IMG: Program Blocks (see JavaScript below)]
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
sensors.color3.pauseForColor(ColorSensorColor.Green)
motors.largeD.run(50, 1, MoveUnit.Rotations)
})
```
1) Using the same program, replace the pause until touch 1 block with a pause color 3 for color block
```block
sensors.color3.pauseForColor(ColorSensorColor.Green)
```
2) Select the color you want to detect (e.g., green).
3) 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]
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!
[IMG: EV3 Driving Base]
You have now learned how to control some of the inputs and outputs of the EV3.

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

@ -0,0 +1,114 @@
# Use
[IMG: EV3 Driving Base full w/cuboid]
Build a robot and drive into the world of robotics!
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
[IMG: Apple Picker]
What if your school had a multipurpose robot? How would you use it?
Would you use it to clean the school or plant trees?
## Build Your Driving Base Robot
[IMG: EV3 Driving Base Building Instructions Cover Image]
* [Building instructions](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf)
## Make It Move
[IMG: Program Blocks (see JavaScript below)]
1) 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 steer large B+C motor block inside the 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.
### ~
2) 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
[IMG: Program Blocks (see JavaScript below)]
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(-50, 50, 1, MoveUnit.Rotations)
})
```
1) Create a new program that turns the Driving Base 180 degrees.
### ~ hint
Hint: You will have to modify the turn ratio and the number of rotations until the robot reaches 180 degrees.
### ~
2) 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
[IMG: EV3 Ultrasonic Sensor Driving Base Building Instructions Main Image]
* [building instructions](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-ultrasonic-sensor-driving-base-61ffdfa461aee2470b8ddbeab16e2070.pdf)
## Detect an Object
[IMG: Program Blocks (see JavaScript below)]
1 - 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 tank large B+C motor block inside the on button block
* Drag a threshold Ultrasonic Sensor block and place below the motor block
* Drag a 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.
### ~
2) 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 and change and test the number value of the Ultrasonic Sensor
```typescript
sensors.ultrasonic4.setThreshold(UltrasonicSensorEvent.ObjectDetected, 10)
```
[IMG: EV3 Ultrasonic Sensor Driving Base Building Instructions Main Image]
**Congratulations!**
You are ready to move on to the next steps.
Try a LEGO MINDSTORMS Design Engineering, Coding, or Maker activity.

View File

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

248
docs/labview.md Normal file
View File

@ -0,0 +1,248 @@
# Coding in MakeCode
This guide helps users who are used to the LabView LEGO Minstorms editor quickly get familiar with using blocks in MakeCode.
## Snap together the blocks
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.
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 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.run(50)
pause(1000)
motors.largeA.stop()
```
Any block program can be converted to JavaScript and you can edit it as lines of code too.
```typescript
motors.largeA.run(50)
pause(1000)
motors.largeA.stop()
```
## Download to the EV3
Before you actually run your program on the @boardname@, 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 @boardname@, click the ``|Download|`` button and follow the instructions.
## Single motors
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.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 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)
```blocks
motors.largeBC.steer(0, 50);
motors.largeBC.steer(0, 50, 1000, MoveUnit.MilliSeconds);
motors.largeBC.steer(0, 50, 360, MoveUnit.Degrees);
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations);
motors.largeBC.stop();
```
## Tank
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)
```blocks
motors.largeBC.tank(50, 50);
motors.largeBC.tank(50, 50, 1000, MoveUnit.MilliSeconds);
motors.largeBC.tank(50, 50, 360, MoveUnit.Degrees);
motors.largeBC.tank(50, 50, 1, MoveUnit.Rotations);
motors.largeBC.stop();
```
## Coasting and braking
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.run(50, 1, MoveUnit.Rotations)
```
## Inverting and regulating motors
If you wan to change the direction that a motor turns, use the ``||motors:set inverted||`` block.
![Brake block](/static/labview/invertmotor.png)
```blocks
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 ``||motors:set regulated||``.
![Brake block](/static/labview/unregulatedmotor.png)
```blocks
motors.largeA.setRegulated(false);
```
## Brick
The **Brick** category has a number of blocks to display graphics on the brick screen.
![brick image](/static/labview/brickimage.png)
```blocks
brick.clearScreen()
brick.showImage(images.expressionsWink)
```
![brick status light](/static/labview/brickstatuslight.png)
```blocks
brick.setStatusLight(StatusLight.Off);
brick.setStatusLight(StatusLight.Red);
brick.setStatusLight(StatusLight.OrangePulse);
```
## Waiting (pausing)
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.run(50)
pause(1000)
motors.largeD.stop();
```
![pause for touch](/static/labview/pausefortouch.png)
```blocks
motors.largeD.run(50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeD.stop();
```
![pause for distance](/static/labview/pausefordistance.png)
```blocks
motors.largeD.run(50)
sensors.ultrasonic4.pauseUntil(UltrasonicSensorEvent.ObjectNear)
motors.largeD.stop();
```
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.run(50)
pauseUntil(() => sensors.touch1.isPressed())
motors.largeD.stop()
```
## Loops
![Single loop](/static/labview/loopinfinite.png)
```blocks
forever(() => {
motors.largeD.run(50, 1, MoveUnit.Rotations);
motors.largeD.run(-50, 1, MoveUnit.Rotations);
})
```
![While loop](/static/labview/while.png)
```blocks
for(let i = 0; i < 10; i++) {
motors.largeD.run(50, 1, MoveUnit.Rotations);
motors.largeD.run(-50, 1, MoveUnit.Rotations);
}
let k = 0;
while(k < 10) {
motors.largeD.run(50, 1, MoveUnit.Rotations);
motors.largeD.run(-50, 1, MoveUnit.Rotations);
k++;
}
```
## Variables
![Variable block](/static/labview/speedoflightvar.png)
```blocks
let light = 0;
forever(function () {
light = sensors.color3.light(LightIntensityMode.Reflected);
motors.largeD.run(light)
})
```
## Concurrent loops
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).
![Multiple loops running at the same time](/static/labview/multipleloops.png)
```blocks
forever(() => {
motors.largeD.run(50, 1, MoveUnit.Rotations);
motors.largeD.run(-50, 1, MoveUnit.Rotations);
})
forever(() => {
brick.showImage(images.eyesMiddleRight)
pause(1000)
brick.showImage(images.eyesMiddleLeft)
pause(1000)
})
```
## Conditional
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
forever(function() {
if(sensors.touch1.isPressed()) {
motors.largeD.run(50)
} else {
motors.largeD.stop()
}
})
```
## Random
The ``||math:pick random||`` block returns a random number selected from a range of numbers.
![Brake block](/static/labview/random.png)
```blocks
forever(function () {
motors.largeBC.steer(Math.randomRange(-5, 5), 50)
pause(100)
})
```

27
docs/lessons.md Normal file
View File

@ -0,0 +1,27 @@
# Lessons
Learning activities for LEGO Mindstorms with MakeCode.
## Motors and motion
```codecard
[{
"name": "Make it Move",
"imageUrl":"/static/lessons/make-it-move.jpg",
"url": "/lessons/make-it-move",
"cardType": "project",
"description": "Make a robot that moves itself without wheels."
}, {
"name": "Make it Move TUTORIAL",
"imageUrl":"/static/lessons/make-it-move.jpg",
"url": "/lessons/make-it-move-tutorial",
"cardType": "tutorial",
"description": "Make a robot that moves itself without wheels."
}, {
"name": "Line Detection",
"imageUrl":"/static/lessons/line-detection.jpg",
"url": "/lessons/line-detection",
"cardType": "project",
"description": "Make your robot drive itself by following lines."
}]
```

View File

@ -0,0 +1,266 @@
# Line Detection
## Objective
Design ways to improve driving safety by helping to prevent drivers from falling asleep and causing an accident.
![Car driving on highway](/static/lessons/line-detection/car-driving.jpg)
## Connect
Make sure that you can answer the following questions:
* 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?
Think about what you have learned, then document it. Describe the problem in your own words. Creatively record your ideas and findings.
## Construct
Start by constructing this model. Read the building instructions [here](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-color-sensor-down-driving-base-d30ed30610c3d6647d56e17bc64cf6e2.pdf) first.
![Color sensor on the driving base](/static/lessons/line-detection/color-sensor-driving.jpg)
## Program
Autonomous cars need to recognize and respond to traffic lights automatically.
First, 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.
There are two coding tasks for this lesson:
1. Create a program that will make your robot stop at red lights.
2. Create a program that drives the robot forward until the Color Sensor sees red. The robot then stops.
## Coding task 1 - Stop at red lights
**Goal:** Create a program that will make your robot stop at red lights.
### Step 1
Create a program that drives the robot forward until the Color Sensor sees red. The robot then stops.
Place a ``||motors:steer large B+C||`` block from ``||motors:Motors||`` under ``||loops:on start||``. Change the speed to 20%.
```blocks
motors.largeBC.steer(0, 20)
```
### Step 2
Place a ``||loops:while||`` loop block under ``||motors:steer large B+C||``.
```blocks
motors.largeBC.steer(0, 20)
while (true) {
}
```
### Step 3
Place a ``||sensors:pause for color||`` 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)
}
```
### Step 4
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause for color||`` block.
Study the program...what do you think the program will do?
**Hint:** The motors will run until the Color Sensor senses the color red, then all motors will stop. The motors will run until the sensor reading in the while block is true.
```blocks
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.stopAll()
}
```
### Step 5
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.
## Coding task 2 - Detect light changes
**Goal:** Program your robot to drive forward again when the light changes from red to green.
### Step 1
Place a ``||loops:while||`` loop block under ``||loops:on start||``.
```blocks
while (true) {
}
```
### Step 2
Place a ``||motors:steer large B+C||`` block from ``||motors:Motors||`` inside the ``||loops:while||`` loop block. Change the speed to 20%.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
}
```
### Step 4
Place a ``||loops:while||`` loop block under the ``||motors:steer large B+C||`` block.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
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.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
}
}
```
### Step 6
Place a ``||motors:stop all motors||`` block under the ``||sensors:pause for color||`` block.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.stopAll()
}
}
```
### Step 7
Place a ``||loops:while||`` loop block under the second ``||loops:while||`` loop block.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.stopAll()
}
while (true) {
}
}
```
### Step 8
Place a ``||sensors:pause for color||`` block inside the new ``||loops:while||`` loop block. Change the color to red.
What do you think the program will do?
**Hint:** The motors will run until the Color Sensor detects the color red, then it will stop all motors. The motors will also run and not stop when the color sensor detects the color green.
```blocks
while (true) {
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
motors.stopAll()
}
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
}
}
```
### Step 9
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
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.
Think about what you have learned, then document it. Describe your pseudocode for this task. Creatively record your ideas, and findings.
### Programming hint
```blocks
motors.largeBC.steer(0, 20)
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Yellow)
music.playSoundEffect(sounds.systemGeneralAlert)
}
while (true) {
while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.run(10)
motors.largeC.run(-10)
}
while (true) {
sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeA.run(-10)
motors.largeA.run(10)
}
}
```
## Continue
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.
### Programming hint
```blocks
while (true) {
while (true) { sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.run(10)
motors.largeC.run(-10)
}
while (true) {
sensors.color3.pauseForLight(LightIntensityMode.Reflected, LightCondition.Bright)
motors.largeB.run(-10)
motors.largeC.run(10)
}
}
```
## Share
Consider the following questions:
1. What challenged you?
2. Where there any surprises?
3. How could you improve your program?
4. Could your program have been more streamlined?
5. Have you used too many blocks?
6. Is there a more efficient way of building your program?
7. How could your program be used in real-world scenarios?
Think about what you have learned, then document it. Creatively record and present your ideas, creations, and findings.

View File

@ -0,0 +1,135 @@
# Make a Security Gadget
![Maker Make a Security Gadget Main Image](/static/lessons/make-a-security-gadget/lego-maker-security.jpg)
Invent a Security Gadget that will protect your belongings by warning you!
## 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/lego-security-gadget.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
* [LEGO MINDSTORMS Education EV3 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 or Object Detection activity before this one. Or, you can start out with this activity and tinker with coding sensor inputs on your own.
### Defining the Problem
![LEGO Education Maker Design Process](/static/lessons/make-a-security-gadget/lego-security-gadget.jpg)
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 LEGO® MINDSTORMS EV3 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.
### Sample Solutions
#### Phone Protector
![Security Gadget Tinkering Example #1 Phone Stand](/static/lessons/make-a-security-gadget/lego-security-gadget.jpg)
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.
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``.
![Tinkering Example #1 Programming Blocks (see JavaScript below)](/static/lessons/make-a-security-gadget/lego-security-gadget.jpg)
```blocks
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
![Security Gadget Tinkering Example #1 Mouse detector](/static/lessons/make-a-security-gadget/lego-security-gadget.jpg)
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.
![Tinkering Example #2 Programming Blocks (see JavaScript below)](/static/lessons/make-a-security-gadget/lego-security-gadget.jpg)
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.
### Well done!
Click [here](#) to try out some more projects!

View File

@ -0,0 +1,157 @@
# Make a Sound Machine
![Maker Make a Sound Machine Main Image](/static/lessons/make-a-sound-machine/lego-maker-sound-machine-1.jpg)
Make a Sound Machine that can play a rhythm, music or just noise!
## 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
* [LEGO MINDSTORMS Education EV3 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 or 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.
### Defining the Problem
![LEGO Education Maker Design Process](/static/lessons/make-a-sound-machine/lego-maker-sound-machine.jpg)
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 LEGO® MINDSTORMS EV3 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.
## Sample Solutions
### Rhythm Maker
![Sound Machine Tinkering Example #1](/static/lessons/make-a-sound-machine/lego-maker-sound-machine.jpg)
This example program combined with the small model will make a beat and rhythm on any surface when the program is run.
![Tinkering Example #1 Programming Blocks (see JavaScript below)](/static/lessons/make-a-sound-machine/lego-maker-sound-machine.jpg)
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
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
![Sound Machine Tinkering Example #1](/static/lessons/make-a-sound-machine/lego-maker-sound-machine.jpg)
You can also tinker with the use of sensors.
![Tinkering Example #2 Programming Blocks (see JavaScript below)](/static/lessons/make-a-sound-machine/lego-maker-sound-machine.jpg)
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.pauseForColor(ColorSensorColor.Blue)
music.playTone(392, music.beat(BeatFraction.Whole))
} else if (false) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
music.playTone(523, music.beat(BeatFraction.Half))
} else {
sensors.color3.pauseForColor(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.
### Well done!
Click [here](#) to try out some more projects!

View File

@ -0,0 +1,72 @@
# Make It Move Without Wheels
## Objective @unplugged
Design, build and program a robot that can move itself:
Your robot will:
* Go a distance of at least 30cm
* Use at least one motor
* Use NO wheels for locomotion
![LECG Mindstorms brick with parts](/static/lessons/make-it-move/locomotion-no-wheels.jpg)
## Construct @unplugged
Build a Walker Bot!
The Walker Bot is one example of many possible solutions for making a robot move without wheels.
The Walker Bot combines an EV3 Frame and two legs that are mirror-images to create left and right legs.
The legs in the Walker Bot are designed to show how to change the rotary motion of a motor to reciprocating 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)
## Program 1 @fullscreen
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 the robot move without using any wheels.
Place a ``||motors:tank large B+C||`` block from ``||motors:Motors||`` under ``||loops:on start||``.
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.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
```
## Program 2 @fullscreen
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.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
motors.stopAll()
```
## Program 3 @fullscreen
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.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
motors.stopAll()
brick.showString("30 cm", 1)
```
## Download @fullscreen
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

@ -0,0 +1,73 @@
# Make It Move Without Wheels
## Objective
Design, build and program a robot that can move itself:
Your robot will:
* Go a distance of at least 30cm
* Use at least one motor
* Use NO wheels for locomotion
![LECG Mindstorms brick with parts](/static/lessons/make-it-move/locomotion-no-wheels.jpg)
## Construct
Build a Walker Bot!
The Walker Bot is one example of many possible solutions for making a robot move without wheels.
The Walker Bot combines an EV3 Frame and two legs that are mirror-images to create left and right legs.
The legs in the Walker Bot are designed to show how to change the rotary motion of a motor to reciprocating 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)
## Program
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 the robot move without using any wheels.
### Step 1
Place a ``||motors:tank large B+C||`` block from ``||motors:Motors||`` under ``||loops:on start||``.
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.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
```
### Step 2
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.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
motors.largeBC.stop()
```
### Step 3
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.
```blocks
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
motors.largeBC.stop()
brick.showString("30 cm", 1)
```
### Step 4
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

@ -9,39 +9,20 @@ These six activities require the LEGO® MINDSTORMS® Education EV3 Core Set (455
```codecard
[
{
"name": "Sound Machine",
"name": "Make A Sound Machine",
"description": "Create instruments with your EV3 Brick!",
"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": "TBD",
"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

@ -2,10 +2,8 @@
This program will activate an alarm when an object moves in front of the Ultrasonic Sensor.
TODO support for event when value changes
```blocks
input.ultrasonic4.onObjectNear(function () {
music.playSoundUntilDone(music.sounds(Sounds.PowerUp))
sensors.ultrasonic4.onEvent(UltrasonicSensorEvent.ObjectNear, function () {
music.playSoundEffectUntilDone(sounds.informationActivate)
})
```

View File

@ -3,15 +3,13 @@
Use this program with the Programmable Brick and Large Motor.
```blocks
loops.forever(function () {
output.largeMotorA.setPower(30)
output.largeMotorA.on(true)
loops.pause(100)
output.largeMotorA.on(false)
music.playSoundUntilDone(music.sounds(Sounds.PowerUp))
output.largeMotorA.setPower(-30)
output.largeMotorA.on(true)
loops.pause(100)
output.largeMotorA.on(false)
forever(function () {
motors.largeA.run(30)
pause(100)
motors.largeA.stop()
music.playSoundEffectUntilDone(sounds.animalsCatPurr)
motors.largeA.run(-30)
pause(100)
motors.largeA.stop()
})
```

View File

@ -3,7 +3,7 @@
This program will activate an alarm when an object is lifted from the Touch Sensor.
```blocks
input.touchSensor1.onEvent(TouchSensorEvent.Released, function () {
music.playSoundUntilDone(music.sounds(Sounds.PowerUp))
sensors.touch1.onEvent(ButtonEvent.Released, function () {
music.playSoundEffectUntilDone(sounds.informationActivate);
})
```

View File

@ -3,10 +3,10 @@
This example program combined with the small model will make a beat and rhythm on any surface when the program is run.
```blocks
loops.forever(function () {
output.motorA.on(50)
loops.pause(200)
output.motorA.on(100)
loops.pause(200)
forever(function () {
motors.largeA.run(50)
pause(200)
motors.largeA.run(100)
pause(200)
})
```

View File

@ -3,13 +3,13 @@
This program will play different sounds when the wheel is rotated. The sound is determined by which color is placed in front of the color Sensor.
```blocks
input.color3.onColorDetected(ColorSensorColor.Blue, function () {
sensors.color3.onColorDetected(ColorSensorColor.Blue, function () {
music.playTone(Note.G4, music.beat(BeatFraction.Half))
})
input.color3.onColorDetected(ColorSensorColor.Red, function () {
sensors.color3.onColorDetected(ColorSensorColor.Red, function () {
music.playTone(Note.C5, music.beat(BeatFraction.Half))
})
input.color3.onColorDetected(ColorSensorColor.Green, function () {
sensors.color3.onColorDetected(ColorSensorColor.Green, function () {
music.playTone(Note.D5, music.beat(BeatFraction.Half))
})
```

View File

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

30
docs/reference/brick.md Normal file
View File

@ -0,0 +1,30 @@
# Brick
## Screen
```cards
brick.showMood(moods.sleeping);
brick.showImage(images.expressionsBigSmile);
brick.showString("Hello world!", 1);
brick.showNumber(0, 1);
brick.showValue("item", 0, 1);
brick.clearScreen();
```
## Buttons
```cards
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
});
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
brick.buttonEnter.isPressed()
brick.buttonEnter.wasPressed()
brick.setStatusLight(StatusLight.Red);
```
## Other
```cards
brick.batteryLevel()
```

View File

@ -0,0 +1,33 @@
# battery Level
Return the current battery level.
```sig
brick.batteryLevel();
```
## Returns
* a [number](/types/number) which is the current charge level of the brick's battery. This is a percentage of total charge left in the battery.
## Example
Show the battery level percentage on the screen. Also, show a green light if the battery level is above 15%. If the battery level is below 15% but above 5%, show a orange light. But, if the battery level is below 5%, show a pulsing red light.
```blocks
let battery = 0;
forever(function() {
brick.showString("Battery level:", 1)
brick.showNumber(battery, 2)
battery = brick.batteryLevel();
if (battery > 15)
{
brick.setStatusLight(StatusLight.Green);
} else if (battery > 5) {
brick.setStatusLight(StatusLight.Orange);
} else {
brick.setStatusLight(StatusLight.RedPulse)
}
pause(30000)
})
```

View File

@ -0,0 +1,53 @@
# is Pressed
Check if a button is being pressed or not.
```sig
brick.buttonEnter.isPressed()
```
## ~hint
**Touch sensors**
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
if (sensors.touch1.isPressed()) {
console.log("Hey, I feel pressed.");
}
```
Read about [touch sensors](/reference/sensors/touch-sensor) and using them as touch buttons.
## ~
## Returns
* a [boolean](types/boolean): `true` if the button is pressed, `false` if the button is not pressed
## Example
Set the brick light to green when the `down` is pressed. When the button is not pressed, the brick light is red.
```blocks
let isRed = false;
forever(function() {
if (brick.buttonLeft.isPressed()) {
brick.setStatusLight(StatusLight.Green);
isRed = false;
} else {
if (!isRed) {
brick.setStatusLight(StatusLight.Red);
isRed = true;
}
}
})
```
## See also
[was pressed](/reference/brick/button/was-pressed),
[on event](/reference/brick/button/on-event)
[Touch sensors](/reference/sensors/touch-sensor)

View File

@ -0,0 +1,57 @@
# on Event
Run some code when a button is clicked, pressed down, or released.
```sig
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
});
```
## ~hint
**Touch sensors**
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
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
brick.setStatusLight(StatusLight.Orange);
});
```
Read about [touch sensors](/reference/sensors/touch-sensor) and using them as touch buttons.
## ~
## Parameters
* **ev**: the button action to run some code for. The button actions (events) are:
> * ``click``: button was clicked (pressed and released)
> * ``up``: button is released from just being pressed
> * ``down``: button is just pressed down
* **body**: the code you want to run when something happens with a button
## Example
Check for event on the ENTER button. Put a message on the screen when the button is pressed, clicked, or released.
```blocks
brick.showString("ENTER is: UP", 1);
brick.buttonEnter.onEvent(ButtonEvent.Released, function () {
brick.showString("ENTER is: UP ", 1);
});
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
brick.showString("ENTER is: DOWN ", 1);
});
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showString("ENTER was: CLICKED", 1);
});
```
### See also
[is pressed](/reference/brick/button/is-pressed),
[was pressed](/reference/brick/button/was-pressed),
[Touch sensor](/reference/sensors/touch-sensor)

View File

@ -0,0 +1,37 @@
# pause Until
Causes your program to wait until an event at a button happens.
```sig
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped);
```
## Parameters
* **ev**: the button action to wait for. The button actions (events) are:
> * ``click``: button was clicked (pressed and released)
> * ``up``: button is released from just being pressed
> * ``down``: button is just pressed down
## Example
Wait for the `up` button to go up before continuing with displaying a message on the screen.
```blocks
let waitTime = 0;
brick.showString("We're going to wait", 1);
brick.showString("for you to press and", 2);
brick.showString("release the UP button", 3);
waitTime = control.millis();
brick.buttonUp.pauseUntil(ButtonEvent.Bumped);
brick.clearScreen();
if (control.millis() - waitTime > 5000) {
brick.showString("Ok, that took awhile!", 1)
} else {
brick.showString("Ah, you let go!", 1)
}
```
## See also
[on event](/reference/brick/button/on-event)

View File

@ -0,0 +1,50 @@
# was Pressed
Check if a button was pressed earlier.
```sig
brick.buttonEnter.wasPressed()
```
The fact that a button was pressed earlier is remembered. Once **was pressed** is used, this fact is forgotten and the result is `false` the next time you check with **was pressed** button _state_ is reset). But, if you press the button again before you check with **was pressed**, it will tell you `true`.
## ~hint
**Touch sensors**
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
if (sensors.touch1.wasPressed()) {
console.log("Hey, I was pressed.");
}
```
Read about [touch sensors](/reference/sensors/touch-sensor) and using them as touch buttons.
## ~
## Returns
* a [boolean](types/boolean): `true` if the button was pressed before, `false` if the button was not pressed before
## Example
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
brick.buttonLeft.onEvent(ButtonEvent.Bumped, function() {
if (brick.buttonRight.wasPressed()) {
brick.setStatusLight(StatusLight.Green)
} else {
brick.setStatusLight(StatusLight.Off)
}
})
```
## See also
[is pressed](/reference/brick/button/is-pressed),
[on event](/reference/brick/button/on-event)
[Touch sensors](/reference/sensors/touch-sensor)

View File

@ -0,0 +1,22 @@
# clear Screen
Clear any text or numbers displayed on the screen. The screen will be blank.
```sig
brick.clearScreen();
```
## Example
Clear the screen after displaying the message.
```blocks
brick.showString("This message will", 1);
brick.showString("self-destruct in:", 2);
brick.showString("seconds", 5);
for (let i = 0; i < 10; i++) {
brick.showNumber(10 - i, 4);
pause(1000);
}
brick.clearScreen();
```

View File

@ -0,0 +1,37 @@
# set Light
Set the light on the brick to a solid or flashing color.
```sig
brick.setStatusLight(StatusLight.Red);
```
## Parameters
* **pattern**: the color or color pattern for the brick light to show. The brick light can have these color patterns:
>* `off`: brick light is off
>* `green`: solid green
>* `red`: solid red
>* `orange`: solid orange
>* `green flash`: flashing green
>* `red flash`: flashing red
>* `orange flash`: flashing orange
>* `green pulse`: pulsing green
>* `red pulse`: pulsing red
>* `orange pulse`: pulsing orange
## Example
Repeatedly show a different color pattern for the brick light.
```blocks
forever(function () {
brick.setStatusLight(StatusLight.Orange)
pause(1000)
brick.setStatusLight(StatusLight.GreenFlash)
pause(2000)
brick.setStatusLight(StatusLight.RedPulse)
pause(2000)
brick.setStatusLight(StatusLight.Off)
pause(500)
})
```

View File

@ -0,0 +1,24 @@
# show Image
Show an image on the brick's display.
```sig
brick.showImage(images.expressionsBigSmile);
```
You can choose one of several images to show on the display.
## Parameters
**image**: A image to show on the brick's display. Use the image picker to choose the image you want to show.
## Example
Show a sleeping image on the brick's display.
```blocks
brick.showImage(images.expressionsZzz)
```
## See also
[show image](/reference/brick/show-mood)

View File

@ -0,0 +1,24 @@
# show Number
Show a number on the screen at the line you select.
```sig
brick.showNumber(0, 1);
```
## Parameters
* **value**: a [number](/types/number) to show on the brick's screen.
* **line**: The line number on the screen where the value is displayed. The line numbers for the screen start with line `1`.
## Example
Show the number `1000` on the screen.
```blocks
brick.showNumber(1000, 1);
```
## See also
[show string](/reference/brick/show-string), [show value](/reference/brick/show-value)

View File

@ -0,0 +1,29 @@
# show String
Show some text on a the screen at the line you select.
```sig
brick.showString("Hello world", 1)
```
## Parameters
* **text**: a [string](/types/string) to show on the brick's screen.
* **line**: the line [number](/types/number) on the screen where the text is displayed. The line numbers for the screen start with line `1`.
## Example
Show a greeting on the screen. Then, respond with another message when ENTER is pressed.
```blocks
brick.showString("Hello, I dare you to", 1);
brick.showString("press ENTER...", 2);
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showString("Hey! Don't push my", 4);
brick.showString("buttons.", 5);
});
```
## See also
[show number](/reference/brick/show-number)

View File

@ -0,0 +1,29 @@
# show Value
Show a name-value-pair on the screen at the line you select.
```sig
brick.showValue("item", 0, 1);
```
Name-value-pairs are used to report data values to the screen. If you want to show the current temperature on the screen, you might use `"temp"` as the data name for the the value.
## Parameters
* **name**: a [string](/types/string) which is the name of the data value.
* **value**: a [number](/types/number) to show on the brick's screen.
* **line**: The line number on the screen where the value is displayed. The line numbers for the screen start with line `1`.
## Example
Show the current amount of ambient light detected by sensor 2.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Bumped, function () {
brick.showValue("color", sensors.color2.light(LightIntensityMode.Ambient), 1)
})
```
## See also
[show number](/reference/brick/show-number)

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 @boardname@, 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
}
}
```

24
docs/reference/motors.md Normal file
View File

@ -0,0 +1,24 @@
# Motors
## Motion
```cards
motors.largeA.run(50)
motors.largeAB.tank(50, 50)
motors.largeAB.steer(0, 50)
motors.largeA.pauseUntilReady()
motors.largeA.setBrake(false)
motors.largeA.setInverted(true)
motors.largeA.setRegulated(false)
motors.largeA.stop()
motors.largeA.reset()
motors.stopAll()
```
## Counters
```cards
motors.largeA.speed()
motors.largeA.angle()
motors.largeA.tacho()
motors.largeA.clearCounts()
```

View File

@ -0,0 +1,31 @@
# angle
Get the current angle of the motor's rotation in degrees.
```sig
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 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.
## Example
Reset the motor connected to port **A** and run it for for 2 seconds at a speed of `45`. Stop and get the current angle of rotation.
```blocks
let motorAngle = 0;
motors.largeA.reset()
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),
[reset](/reference/motors/motor/reset), [clear counts](/reference/motors/motor/clear-counts)

View File

@ -0,0 +1,35 @@
# clear Counts
Set all counters for the motor back to zero.
```sig
motors.largeA.clearCounts()
```
The counters for a motor are: **tacho**, **angle**, and **speed**. Each of these counters is set to start counting from `0` again. This is a way to begin new counts without having to reset the motor.
## Example
See if the motor turns the same number of times for each of two count periods. Run the motor connected to port **A** twice for 10 seconds and compare the tacho counts.
```blocks
let tachoCount = 0;
motors.largeA.reset()
motors.largeA.run(50)
pause(10000)
tachoCount = motors.largeA.tacho()
motors.largeA.clearCounts()
motors.largeA.run(50)
pause(10000)
if (tachoCount == motors.largeA.tacho()) {
brick.showString("Motor turns equal.", 1)
} else {
brick.showString("Motor turns NOT equal.", 1)
}
motors.largeA.stop()
```
## See also
[tacho](/reference/motors/motor/tacho), [angle](/reference/motors/motor/angle),
[speed](/reference/motors/motor/speed), [reset](/reference/motors/motor/reset)

View File

@ -0,0 +1,30 @@
# reset
Reset the motor's speed setting and it's counters.
```sig
motors.largeA.reset()
```
The motor's speed is set back to `0` and the **tacho**, **angle**, and **speed** counters are set to `0`.
## Example
See what the angle count is when a motor is stopped. Then, try it again after a reset.
```blocks
motors.largeA.run(30)
pause(2000)
motors.largeA.stop()
brick.showString("Angle count:", 1)
brick.showNumber(motors.largeA.angle(), 2)
motors.largeA.run(30)
pause(2000)
motors.largeA.reset()
brick.showString("Angle count:", 4)
brick.showNumber(motors.largeA.angle(), 5)
```
## See also
[stop](/reference/motors/motor/stop), [clear counts](/reference/motors/motor/clear-counts)

View File

@ -0,0 +1,96 @@
# run
Set the rotation speed of the motor as a percentage of maximum speed.
```sig
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.
If you use just the **speed** number, the motor runs continously and won't stop unless you tell it to. You can also give a value for a certain amount of distance you want the motor to rotate for. The **value** can be an amount of time, a turn angle in degrees, or a number of full rotations.
If you decide to use a **value** of rotation distance, you need to choose a type of movement **unit**.
## ~hint
If you use a number of milliseconds as movement units, then you don't need to include the unit type.
To run the motor for 500 milliseconds:
```block
motors.largeA.run(50, 500)
```
## ~
Here is how you use each different movement unit to run the motor for a fixed rotation distance.
```blocks
// Run motor for 700 Milliseconds.
motors.largeA.run(25, 700, MoveUnit.MilliSeconds);
// Run motor for 700 Milliseconds again but no units specified.
motors.largeA.run(25, 700);
// Run the motor for 45 seconds
motors.largeA.run(50, 45, MoveUnit.Seconds);
// Turn the motor for 270 degrees
motors.largeA.run(50, 270, MoveUnit.Degrees)
// Turn the motor at full speed for 9 full rotations
motors.largeA.run(100, 9, MoveUnit.Rotations);
```
## Parameters
* **speed**: a [number](/types/number) that is the percentage of full speed. A negative value runs the motor in the reverse direction.
* **value**: the [number](/types/number) of movement units to rotate for. A value of `0` means run the motor continuously.
* **unit**: the movement unit of rotation. This can be `milliseconds`, `seconds`, `degrees`, or `rotations`. If the number for **value** is `0`, this parameter isn't used.
## ~hint
** Reverse is negative speed**
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.run(-25)
```
## ~
## Examples
### Drive the motor for 20 seconds
Run the motor connected to port **A** continuously. Pause 20 seconds and then stop the motor.
```blocks
motors.largeA.run(75)
pause(20000)
motors.largeA.stop()
```
### Backwards motion
Run the motor connected to port **A** in reverse. Pause 5 seconds and then stop the motor.
```blocks
motors.largeA.run(-60)
pause(5000)
motors.largeA.stop()
```
### Run the motor for 35 rotations
Run the motor connected to port **B** for 35 full rotations and then stop.
```blocks
motors.largeB.run(50, 35, MoveUnit.Rotations)
```
## See also
[tank](/reference/motors/synced/tank), [steer](/reference/motors/synced/steer), [stop](/reference/motors/motor/stop)

View File

@ -0,0 +1,30 @@
# set Brake
Set the brake on the motor so it won't turn when it has no power.
```sig
motors.largeA.setBrake(false)
```
When a the motor is stopped, it can still rotate if an external force is applied to it. This can happen, for example, if your're tanking your brick on a inclined surface and stop the motors. Gravity will push down on the brick and might cause it to start rolling again. You can prevent this movement by setting the brake.
Also, you can use the brake to do simple skid steering for your brick.
## Paramters
* **brake**: a [boolean](/types/boolean) value which is either `true` to set the brake on or `false` to set the brake off.
## Example
Run the motor connected to port **A** for 2 seconds at a speed of `30`. Stop and set the brake.
```blocks
motors.largeA.run(30)
pause(2000)
motors.largeA.stop()
motors.largeA.setBrake(true)
```
## See also
[stop](/reference/motors/motor/stop)

View File

@ -0,0 +1,32 @@
# set Reversed
Change the direction of rotation for a motor.
```sig
motors.largeA.setInverted(true)
```
You use a positive value (some number greater than `0`) to drive you motor in the default direction. If you're using a motor in a way that makes more sense for your program to use a negative speed setting for that direction, you can reverse the speed range.
## Paramters
* **reversed**: a [boolean](/types/boolean) value that is `false` if the motor will use a speed value between `0` and `100` to turn in the default direction. If `true`, the motor uses a speed value between `0` and `-100` to turn in the default direction.
## Example
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.run(30)
pause(2000)
motors.largeA.stop()
pause(2000)
motors.largeA.setInverted(true)
motors.largeA.run(-30)
pause(2000)
motors.largeA.stop()
```
## See also
[stop](/reference/motors/motor/stop)

View File

@ -0,0 +1,32 @@
# set Regulated
Tell a motor to regulate its speed or not.
```sig
motors.largeA.setRegulated(true)
```
In order for a motor to always rotate at a constant speed it needs regulation. This means that the motor control electronics need to continously measure how much rotation has happened. The controller takes several rotation counts for a small amount of time and compares them to see if the speed is changing. The output power is adjusted if the controller detects that the motor is running too slow or too fast.
If it's not regulated, your motor can change from the speed that you've set for it. Some examples are if your brick is driving forward and bumps into an object or it drives up a slope creating more load on the motor. In theses situations, if your motor speed is regulated, the controller will boost the power to the motor to keep it's speed from slowing down. Another example is when you run the motors to drive your brick down a slope. In this case, the motors would go faster than the speed you set for them if not regulated. To regulate this the controller reduces the power output to the motors to keep the brick from going faster.
Motor regulation is always set to **ON** when your program first starts or the motor is reset.
## Paramters
* **value**: a [boolean](/types/boolean) value which means that the motor speed is regulated if `true`. The motor speed is not regulated when this is `false`.
## Example
Turn off the speed regulation for the motor connected to port **A**.
```blocks
motors.largeA.setRegulated(false)
motors.largeA.run(75)
pause(20000)
motors.largeA.stop()
```
## See also
[run](/reference/motors/motor/run), [stop](/reference/motors/motor/stop)

View File

@ -0,0 +1,33 @@
# speed
Get the current speed of motor rotation as a percentage of maximum speed.
```sig
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 speed you told it to run at (your desired or _set point_ speed) when a force, or load, is applied to it.
## Returns
* a [number](/types/number) which is the motor's current speed. This value is a percentage of maximum speed from `0` to `100`. This number is negative, like `-27`, if the direction of rotation is in reverse.
## Example
Turn speed regulation off and report the actual speed of the large motor in the forward direction. Occasionally touch the wheel on the motor to see if it changes the speed.
```blocks
motors.largeA.setRegulated(false)
motors.largeA.run(55)
brick.showString("Actual speed:", 1)
for (let i = 0; i < 30; i++) {
pause(500)
brick.showNumber(motors.largeA.speed(), 3)
}
motors.largeA.stop()
```
## See also
[tacho](/reference/motors/motor/tacho), [speed](/reference/motors/motor/speed),
[reset](/reference/motors/motor/reset), [clear counts](/reference/motors/motor/clear-counts)

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