Compare commits

..

9 Commits

Author SHA1 Message Date
5958157a76 1.1.21 2019-09-09 09:04:28 -07:00
f72b825377 reenable permanent storage (#909) 2019-09-09 09:04:12 -07:00
d76af5e5af moving turtle 2019-09-08 21:36:04 -07:00
23f48db20b added turtle program 2019-09-08 21:29:27 -07:00
2975bf2b55 Console to dmesg (#910)
* always pip console.log to dmesg

* trim new line

* restore storage

* restore new line

* remove unused variable
2019-09-07 18:22:39 -07:00
5314515619 Crane mission (#907)
* dummy page

* robot 1 lesson

* added lesson 2

* added mission 2

* added link
2019-09-06 16:10:33 -07:00
75b2db9f67 releasing to 1.1.20 (#908) 2019-09-06 14:24:19 -07:00
cf2e39f1b2 renamed tutorial 2019-09-06 08:47:56 -07:00
6d15d69aa1 updated fll page 2019-09-06 08:33:25 -07:00
16 changed files with 280 additions and 17 deletions

View File

@ -212,6 +212,12 @@ Here are some fun programs for your @boardname@!
"description": "Keep your brick entertained and happy",
"url":"/examples/happy-unhappy",
"cardType": "example"
}, {
{
"name": "Turtle",
"description": "Encode moves and run them on a driving base",
"url":"/examples/turtle",
"cardType": "example"
}, {
"name": "Distance Measurer",
"description": "Use a motor to measure angle and distance",

View File

@ -2,7 +2,9 @@
![FIRST LEGO League logo](/static/fll/fll-logo.png)
**For teams participating in the Open Software Platform Pilot utilizing MakeCode**, weve compiled a list of resources and information that we hope will be helpful for you.
**For teams participating in City Shaper challenge**, you can use MakeCode for your challenge (see [City Shaper Challenge, page 7 bottom](https://firstinspiresst01.blob.core.windows.net/fll/2020/city-shaper-game-guide-pdf.pdf)!
Weve compiled a list of resources and information that we hope will be helpful for you.
* **Got a question? Post it on the forums** at https://forum.makecode.com/
@ -18,17 +20,15 @@ If you found a bug, please try if it hasn't been fixed yet! Go to https://makeco
* You will need a computer with a USB port to connect to the EV3 in order to download your programs.
* You will need internet access and a browser on your computer to get to https://makecode.mindstorms.com.
### I know LabView, how is MakeCode different?
We have compiled a guide for EV3 LabView users at https://makecode.mindstorms.com/labview.
### Whats the best way to get started with MakeCode?
Watch some of the videos at https://makecode.mindstorms.com (at the bottom of the page).
Try some of the provided tutorials:
Go to https://makecode.mindstorms.com. The home screen is filled with videos, tutorials and examples that might be relevant for your missions.
* [Wake Up!](@homeurl@#tutorial:tutorials/wake-up) show your EV3 brick waking up
* [Animation](@homeurl@#tutorial:tutorials/make-an-animation) create a custom animation to show
* [Music Brick](@homeurl@#tutorial:tutorials/music-brick) transform your EV3 into a musical instrument
* [Run Motors](@homeurl@#tutorial:tutorials/run-motors) control the motors of your robot
* [Red Light, Green Light](@homeurl@#tutorial:tutorials/redlight-greenlight) play red light, green light with the color sensor
* [Line Following](@homeurl@#tutorial:tutorials/line-following) have your robot follow a line
On the home page, scroll down to the **FLL / City Shaper / Crane Mission** section for specific lessons related to Mission 2.
### Can I load both LEGO MINDSTORMS EV3 Software and MakeCode programs onto my EV3?

View File

@ -1,3 +1,3 @@
{
"appref": "v1.0.11"
"appref": "v1.1.20"
}

View File

@ -0,0 +1,27 @@
# Crane Mission Lessons
The [Crane Mission Lessons](https://firstinspiresst01.blob.core.windows.net/fll/2020/fll-ev3-overview.pdf) adapted for MakeCode.
## Lessons
```codecard
[
{
"name": "Crane Mission / Robot 1",
"description": "Learn the basics and build your first robot driving base.",
"cardType": "tutorial",
"url":"/tutorials/city-shaper/robot-1"
}, {
"name": "Crane Mission / Robot 2",
"description": "Program your robot to move in different ways.",
"cardType": "tutorial",
"url":"/tutorials/city-shaper/robot-2"
}
]
```
## See Also
[Robot 1](/tutorials/city-shaper/robot-1),
[Robot 2](/tutorials/city-shaper/robot-2)

View File

@ -0,0 +1,20 @@
# Mission 2 Lesson
Use the program below to tell your robot how to solve the Crane Mission (Mission 2).
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 25, 2.25, MoveUnit.Rotations)
control.timer1.reset()
while (control.timer1.seconds() < 1.5) {
motors.largeBC.steer(sensors.color1.light(LightIntensityMode.Reflected) - 40, 50)
}
motors.largeBC.stop()
motors.largeBC.steer(0, 15, 0.25, MoveUnit.Rotations)
motors.mediumA.run(25, 60, MoveUnit.Degrees)
pause(2000)
motors.mediumA.run(-25, 1, MoveUnit.Seconds)
motors.largeBC.steer(0, -100, 4, MoveUnit.Rotations)
})
motors.largeBC.setBrake(true)
```

View File

@ -0,0 +1,41 @@
# Robot 1 Lesson
## Step 1 Build Your Driving Base Robot @unplugged
Build the robot driving base:
[![EV3 Driving Base](/static/lessons/common/ev3-driving-base.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf)
If clicking the above image doesn't open the instructions, right-click on the image and choose "Save link as..." to download the PDF.
## Step 2 Show an image @fullscreen
It's useful to know that your program is running. Plug a ``||brick:show mood||`` from the **BRICK** toolbox
inside the ``||loops:on start||`` block. Change the image if you want!
```blocks
brick.showMood(moods.neutral)
```
## Step 3 Try your code @fullscreen
Look at the simulator and check that your image is showing up. When you are ready, press the **DOWNLOAD** button
and follow the instructions to transfer your code on the brick.
## Step 4 Steer motors @fullscreen
Drag a ``||motors:steer motors||`` block from the **MOTORS** toolbox and snap it under ``||brick:show mood||``.
Click on the plus and make sure to tell your motors to turn **1** rotation.
```blocks
brick.showMood(moods.neutral)
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations)
```
## Step 5 Try your code @fullscreen
Whenever you make a code change, the simulator will restart and you can preview what your code will do there.
When you are ready, click **DOWNLOAD** and follow the instructions to transfer the code into your brick.
**Remember** Take the driving base apart at the end of the session, so the other group can build it next time

View File

@ -0,0 +1,94 @@
# Robot 2 Lesson
## Step 1 Build Your Driving Base Robot @unplugged
Build the robot driving base:
[![EV3 Driving Base](/static/lessons/common/ev3-driving-base.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-rem-driving-base-79bebfc16bd491186ea9c9069842155e.pdf)
If clicking the above image doesn't open the instructions, right-click on the image and choose "Save link as..." to download the PDF.
## Step 2 Show an image and move @fullscreen
Add the blocks to show an image and move the motors **B+C** for ``1`` rotation.
```blocks
brick.showMood(moods.neutral)
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations)
```
## Step 6 Brick button @fullscreen
Let's change the code so that your robot moves when the **UP** button is pressed.
Add a ``||brick:on button enter||`` block and move the ``||motors:steer motors||`` under it.
After downloading your code, press **UP** to move the robot.
```blocks
brick.buttonUp.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations)
})
brick.showMood(moods.neutral)
```
## Step 6 Braking @fullscreen
When the motors are done turning, the robot keeps on moving for a short distance.
Turn on the **brakes**, so that your robot stops immediately.
Drag a ``||motors:set brake||`` block into the ``||loops:on start||`` and set it **ON** to the BC motors.
```blocks
brick.buttonUp.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations)
})
brick.showMood(moods.neutral)
motors.largeBC.setBrake(true)
```
## Step 8 Left and Right turn @fullscreen
Let's make the robot turn to the left when the **LEFT** button is pressed on the brick (and same for the right button).
Add a ``||steer motors||`` and change the turn ratio to go left.
```blocks
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(-50, 50, 1, MoveUnit.Rotations)
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(50, 50, 1, MoveUnit.Rotations)
})
```
## Step 9 Backwards @fullscreen
Let's make the robot turn to the right when the **RIGHT** button is pressed on the brick.
Add a ``||steer motors||`` and change the speed to be negative. This will make the motor go backwards.
```blocks
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, -50, 1, MoveUnit.Rotations)
})
```
## Step 10 Add a Ultrasonic sensor @fullscreen
Add a Ultrasonic sensor to your driving base.
[![EV3 Driving Base with Ultrasonic Sensor](/static/lessons/common/ev3-ultrasonic-sensor-driving-base.jpg)](https://le-www-live-s.legocdn.com/sc/media/lessons/mindstorms-ev3/building-instructions/ev3-ultrasonic-sensor-driving-base-61ffdfa461aee2470b8ddbeab16e2070.pdf)
If clicking the above images don't open the instructions, right-click on the image and choose "Save link as..." to download the PDF.
## Step 11 @fullscreen
Create a program that moves the Driving Base and makes it stop 6 cm from the Cuboid.
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
motors.largeBC.steer(0, 50)
pauseUntil(() => sensors.ultrasonic4.distance() < 6)
motors.largeBC.stop()
})
```
Try sending your robot towards a wall!

View File

@ -39,6 +39,11 @@
"cardType": "example",
"url":"/tutorials/coast-or-brake",
"imageUrl":"/static/tutorials/coast-or-brake.png"
}, {
"name": "Turtle",
"description": "Encode moves and run them on a driving base",
"url":"/examples/turtle",
"cardType": "example"
}]
```
@ -49,4 +54,5 @@
[Pivot Turn](/tutorials/pivot-turn),
[Smooth Turn](/tutorials/smooth-turn),
[Tank ZigZag](/tutorials/tank-zigzag),
[Coast Or Brake](/tutorials/coast-or-brake)
[Coast Or Brake](/tutorials/coast-or-brake),
[Turtle](/tutorials/turtle)

View File

@ -0,0 +1,9 @@
# Stop At Object
This is a code example to detect contact or collision with another object. It uses a touch sensor to detect hitting a wall or other obstacle. The motors are run and then stopped when the sensor is pressed.
```blocks
motors.largeBC.tank(50, 50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed)
motors.largeBC.stop()
```

View File

@ -16,10 +16,10 @@
"url":"/tutorials/touch-sensor-values",
"imageUrl":"/static/tutorials/touch-sensor-values.png"
}, {
"name": "Pause Until Pressed",
"name": "Stop At Object",
"description": "Waits for the sensor to be pressed before continuing the program",
"cardType": "tutorial",
"url":"/tutorials/pause-until-pressed",
"url":"/tutorials/stop-at-object",
"imageUrl":"/static/tutorials/pause-until-pressed.png"
}]
```
@ -28,4 +28,4 @@
[Touch to Run](/tutorials/touch-to-run),
[Touch Sensor Values](/tutorials/touch-sensor-values),
[Pause Until Pressed](/tutorials/pause-until-pressed)
[Stop At Object](/tutorials/stop-at-object)

52
docs/tutorials/turtle.md Normal file
View File

@ -0,0 +1,52 @@
# Turtle
A fun interactive program where the user enters a sequence of moves using the buttons and the robot executes it.
```blocks
/**
* Run this program with a driving base.
**/
let indent = ""
let command = ""
let c = ""
brick.buttonLeft.onEvent(ButtonEvent.Pressed, function () {
command = command + "L"
})
brick.buttonRight.onEvent(ButtonEvent.Pressed, function () {
command = command + "R"
})
brick.buttonUp.onEvent(ButtonEvent.Pressed, function () {
command = command + "F"
})
brick.buttonDown.onEvent(ButtonEvent.Pressed, function () {
command = command + "B"
})
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
indent = ""
for (let index = 0; index <= command.length; index++) {
c = command[index]
brick.showString("" + indent + c, 4)
indent = "" + indent + " "
if (c == "L") {
motors.largeBC.steer(-100, 50, 378, MoveUnit.Degrees)
} else if (c == "R") {
motors.largeBC.steer(100, 50, 378, MoveUnit.Degrees)
} else if (c == "F") {
motors.largeBC.steer(0, 50, 1, MoveUnit.Rotations)
} else if (c == "B") {
motors.largeBC.steer(0, -50, 1, MoveUnit.Rotations)
}
}
command = ""
brick.showString("", 2)
})
motors.largeBC.setBrake(true)
forever(function () {
brick.showString("TURTLE", 1)
brick.showString(command, 3)
brick.showString("up/down: forward/backward", 8)
brick.showString("left/right: turn", 9)
brick.showString("enter: play commands", 10)
})
```

View File

@ -1,5 +1,7 @@
// This is the last thing executed before user code
console.addListener(function(msg: string) {
control.dmesg(msg.substr(0, msg.length - 1))
})
// pulse green, play startup sound, turn off light
brick.setStatusLight(StatusLight.GreenPulse);
// We pause for 100ms to give time to read sensor values, so they work in on_start block

View File

@ -199,4 +199,10 @@ namespace storage {
return '/' + filename;
}
}
/**
* Permanent storage on the brick, must be deleted with code.
*/
//% whenUsed fixedInstance block="permanent"
export const permanent: Storage = new PermanentStorage();
}

View File

@ -3,7 +3,6 @@ namespace storage {
storage.temporary.remove("console.txt");
console.addListener(function(line) {
const fn = "console.txt";
const mxs = 65536;
const t = control.millis();
storage.temporary.appendLine(fn, `${t}> ${line}`);
storage.temporary.limit(fn, 65536);

View File

@ -1,6 +1,6 @@
{
"name": "pxt-ev3",
"version": "1.1.20",
"version": "1.1.21",
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
"private": false,
"keywords": [

View File

@ -15,6 +15,7 @@
"Color Sensor Tutorials": "tutorials/color-sensor",
"Ultrasonic Sensor Tutorials": "tutorials/ultrasonic-sensor",
"Infrared Sensor Tutorials": "tutorials/infrared-sensor",
"FLL / City Shaper / Crane Mission": "tutorials/city-shaper/crane-mission",
"Design Engineering": "design-engineering",
"Coding": "coding",
"Maker": "maker",