adding touch button examples

This commit is contained in:
Peli de Halleux
2017-11-28 15:23:54 -08:00
parent 52816e6de7
commit 71479d0caa
6 changed files with 44 additions and 17 deletions

View File

@ -0,0 +1,19 @@
# Happy unhappy
Use a touch sensor to make the brick happy.
```blocks
sensors.touchSensor1.onEvent(TouchSensorEvent.Pressed, function () {
brick.showImage(images.expressionsBigSmile)
})
sensors.touchSensor1.onEvent(TouchSensorEvent.Released, function () {
brick.showImage(images.expressionsSick)
})
loops.forever(function () {
if (sensors.touchSensor1.isTouched()) {
brick.setStatusLight(LightsPattern.Green)
} else {
brick.setStatusLight(LightsPattern.Orange)
}
})
```