adding touch button examples
This commit is contained in:
@ -4,5 +4,12 @@ Here are some fun programs for your @boardname@!
|
||||
|
||||
## Fun stuff
|
||||
|
||||
|
||||
Coming soon.
|
||||
```codecard
|
||||
[
|
||||
{
|
||||
"name": "Happy unhappy",
|
||||
"description": "Keep your brick entertained and happy",
|
||||
"url":"/examples/happy-unhappy",
|
||||
"cardType": "example"
|
||||
}]
|
||||
```
|
19
docs/examples/happy-unhappy.md
Normal file
19
docs/examples/happy-unhappy.md
Normal 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)
|
||||
}
|
||||
})
|
||||
```
|
Reference in New Issue
Block a user