pxt-calliope/docs/projects/light-monster/code.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

29 lines
592 B
Markdown

# Code
## @description code to make the coffee cup monster alive
## ~avatar avatar
Add code to open the mouth when light is detected.
## ~
## Duration: ~30 minutes
We are going to add code to open the mouth proportionally to the amount of light on the @boardname@.
In a loop, we will read the light and map it to an angle using the ``pins.map`` function.
```blocks
basic.forever(() => {
pins.servoWritePin(AnalogPin.P0, pins.map(
input.lightLevel(),
0,
255,
30,
150
))
})
```
## ~button /projects/light-monster/connect
NEXT: Connect
## ~