light the way activities

This commit is contained in:
Peli de Halleux 2018-01-05 19:14:55 -08:00
parent 94c4e508fe
commit 931987468a
9 changed files with 78 additions and 19 deletions

View File

@ -4,7 +4,7 @@
* [Download Curriculum Materials](https://education.lego.com/en-us/downloads/mindstorms-ev3)
## Activites
## Three Point Turn
```codecard
[
@ -23,7 +23,13 @@
"description": "Activity 3",
"url":"/coding/three-point-turn-3",
"cardType": "example"
}, {
}]
```
## Reversing the robot
```codecard
[{
"name": "Reversing the robot",
"description": "Activity 1",
"url":"/coding/reversing-the-robot-1",
@ -38,6 +44,27 @@
"description": "Activity 3",
"url":"/coding/reversing-the-robot-3",
"cardType": "example"
}]
```
## Light the way
```codecard
[{
"name": "Light the way",
"description": "Activity 1",
"url":"/coding/light-the-way-1",
"cardType": "example"
}, {
"name": "Light the way",
"description": "Activity 2",
"url":"/coding/light-the-way-2",
"cardType": "example"
}, {
"name": "Light the way",
"description": "Activity 3",
"url":"/coding/light-the-way-3",
"cardType": "example"
}
]
```

View File

@ -0,0 +1,9 @@
# Light the way Activity 1
```blocks
sensors.color3.onLightChanged(LightIntensityMode.Ambient, LightCondition.Dark, function () {
brick.showImage(images.objectsLightOn)
loops.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(TouchSensorEvent.Pressed, function () {
brick.showImage(images.objectsLightOn);
})
```

View File

@ -223,15 +223,15 @@ namespace sensors {
}
}
//% whenUsed block="color 3" weight=90 fixedInstance jres=icons.port3
export const color3: ColorSensor = new ColorSensor(3)
//% whenUsed block="color 1" weight=95 fixedInstance jres=icons.port1
export const color1: ColorSensor = new ColorSensor(1)
//% whenUsed block="color 2" weight=90 fixedInstance jres=icons.port2
export const color2: ColorSensor = new ColorSensor(2)
//% whenUsed block="color 3" weight=90 fixedInstance jres=icons.port3
export const color3: ColorSensor = new ColorSensor(3)
//% whenUsed block="color 4" weight=90 fixedInstance jres=icons.port4
export const color4: ColorSensor = new ColorSensor(4)
}

View File

@ -6,10 +6,10 @@
"sensors.TouchSensor.onEvent|block": "on %sensor|%event",
"sensors.TouchSensor.pauseUntil|block": "pause until %sensor|%event",
"sensors.TouchSensor.wasPressed|block": "%sensor|was pressed",
"sensors.touchSensor1|block": "touch 1",
"sensors.touchSensor2|block": "touch 2",
"sensors.touchSensor3|block": "touch 3",
"sensors.touchSensor4|block": "touch 4",
"sensors.touch1|block": "touch 1",
"sensors.touch2|block": "touch 2",
"sensors.touch3|block": "touch 3",
"sensors.touch4|block": "touch 4",
"{id:category}Sensors": "Sensors",
"{id:group}Touch Sensor": "Touch Sensor"
}

View File

@ -1,8 +1,8 @@
sensors.touchSensor1.onEvent(TouchSensorEvent.Pressed, function () {
sensors.touch1.onEvent(TouchSensorEvent.Pressed, function () {
})
sensors.touchSensor2.onEvent(TouchSensorEvent.Bumped, function () {
sensors.touch2.onEvent(TouchSensorEvent.Bumped, function () {
})
sensors.touchSensor3.onEvent(TouchSensorEvent.Released, function () {
sensors.touch3.onEvent(TouchSensorEvent.Released, function () {
})
sensors.touchSensor4.isPressed();
sensors.touchSensor4.wasPressed();
sensors.touch4.isPressed();
sensors.touch4.wasPressed();

View File

@ -102,11 +102,11 @@ namespace sensors {
}
//% whenUsed block="touch 1" weight=95 fixedInstance jres=icons.port1
export const touchSensor1: TouchSensor = new TouchSensor(1)
export const touch1: TouchSensor = new TouchSensor(1)
//% whenUsed block="touch 2" weight=95 fixedInstance jres=icons.port2
export const touchSensor2: TouchSensor = new TouchSensor(2)
export const touch2: TouchSensor = new TouchSensor(2)
//% whenUsed block="touch 3" weight=95 fixedInstance jres=icons.port3
export const touchSensor3: TouchSensor = new TouchSensor(3)
export const touch3: TouchSensor = new TouchSensor(3)
//% whenUsed block="touch 4" weight=95 fixedInstance jres=icons.port4
export const touchSensor4: TouchSensor = new TouchSensor(4)
export const touch4: TouchSensor = new TouchSensor(4)
}

View File

@ -3,5 +3,5 @@ tests.test("Touch sensor pressed", function () {
brick.print("and click enter", 0, 60)
brick.buttonEnter.pauseUntil(ButtonEvent.Click)
brick.clearScreen()
tests.assert("Pressed", sensors.touchSensor1.isPressed())
tests.assert("Pressed", sensors.touch1.isPressed())
})