renaming pauseforcolor to pause until color detected (#405)

* renaming pauseforcolor to pause until color detected

* pauseForLight -> pauseUntilLightConditionDetected

* on light changed -> on light condition detected

* fixing docs

* docs tweaks
This commit is contained in:
Peli de Halleux
2018-04-03 05:05:01 -07:00
committed by GitHub
parent 69194b0b76
commit 2467b3c4c9
18 changed files with 78 additions and 76 deletions

View File

@ -99,9 +99,9 @@
* [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)
* [pause until color detected](/reference/sensors/color-sensor/pause-until-color-detected)
* [on-light-condition-detected](/reference/sensors/color-sensor/on-light-condition-detected)
* [pause until light condition detected](/reference/sensors/color-sensor/pause-until-light-condition-detected)
* [color](/reference/sensors/color-sensor/color)
* [light](/reference/sensors/color-sensor/ambient-light)
* [Music](/reference/music)

View File

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

View File

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

View File

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

View File

@ -54,7 +54,7 @@ loops.forever(function () {
})
motors.largeBC.steer(0, 50)
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
```
@ -70,7 +70,7 @@ motors.stopAll()
```blocks
loops.forever(function () {
motors.largeBC.steer(0, 50)
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
})
```
@ -94,9 +94,9 @@ Now add to your program and have your robot to drive forward again when the ligh
```blocks
loops.forever(function () {
motors.largeBC.steer(0, 50)
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
motors.stopAll()
sensors.color3.pauseForColor(ColorSensorColor.Green)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
})
```
@ -134,10 +134,10 @@ music.playSoundEffect(sounds.systemGeneralAlert)
```blocks
loops.forever(function () {
motors.largeBC.steer(-30, 20)
sensors.color3.pauseForColor(ColorSensorColor.Black)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
music.playSoundEffect(sounds.systemGeneralAlert)
motors.largeBC.steer(30, 20)
sensors.color3.pauseForColor(ColorSensorColor.White)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
})
```
@ -185,11 +185,11 @@ if (true) {
```blocks
forever(function () {
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.Black)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
motors.largeBC.steer(-30, 50)
}
while (true) {
sensors.color3.pauseForColor(ColorSensorColor.White)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
motors.largeBC.steer(30, 50)
}
})
@ -204,10 +204,10 @@ Else the Color Sensor detects the color white, start motors ``B`` and ``C`` (dri
```blocks
forever(function () {
if (true) {
sensors.color3.pauseForColor(ColorSensorColor.Black)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Black)
motors.largeBC.steer(-30, 50)
} else {
sensors.color3.pauseForColor(ColorSensorColor.White)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.White)
motors.largeBC.steer(30, 50)
}
})

View File

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

View File

@ -135,7 +135,7 @@ Keeping the Large Motor connected to **Port D**, connect the Color Sensor to **P
```blocks
brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
sensors.color3.pauseForColor(ColorSensorColor.Green)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
motors.largeD.run(50, 1, MoveUnit.Rotations)
})
```
@ -143,7 +143,7 @@ brick.buttonEnter.onEvent(ButtonEvent.Pressed, function () {
* Using the same program, replace the ``||sensors:pause until touch 1||`` block with a ``||sensors:pause color sensor 3||`` for color block.
```block
sensors.color3.pauseForColor(ColorSensorColor.Green)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
```
* Select the color you want to detect (e.g., green).

View File

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

View File

@ -143,13 +143,13 @@ You can also tinker with the use of sensors.
```blocks
forever(function () {
if (true) {
sensors.color3.pauseForColor(ColorSensorColor.Blue)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Blue)
music.playTone(392, music.beat(BeatFraction.Whole))
} else if (false) {
sensors.color3.pauseForColor(ColorSensorColor.Red)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Red)
music.playTone(523, music.beat(BeatFraction.Half))
} else {
sensors.color3.pauseForColor(ColorSensorColor.Green)
sensors.color3.pauseUntilColorDetected(ColorSensorColor.Green)
music.playTone(587, music.beat(BeatFraction.Half))
}
})

View File

@ -4,9 +4,9 @@
```cards
sensors.color1.onColorDetected(ColorSensorColor.Blue, function () {})
sensors.color1.onLightChanged(LightIntensityMode.Reflected, LightCondition.Dark, function () {})
sensors.color1.pauseForLight(LightIntensityMode.Reflected, LightCondition.Dark)
sensors.color1.pauseForColor(ColorSensorColor.Blue)
sensors.color1.onLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark, function () {})
sensors.color1.pauseUntilLightConditionDetected(LightIntensityMode.Reflected, LightCondition.Dark)
sensors.color1.pauseUntilColorDetected(ColorSensorColor.Blue)
sensors.color1.color();
sensors.color1.light(LightIntensityMode.Ambient)
sensors.color(ColorSensorColor.Blue)