pxt-calliope/docs/projects/coffee-cup-monster/code.md
Peli de Halleux 1d47b4de0d Lightmonster (#346)
* fixed boardname issues

* refactored servo info

* coffee cup monster lesson skeleton

* display event source id / value in advanced section

* normalized project structure

* updated project name

* Update projects.md
2017-01-31 08:29:25 -08:00

602 B

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.

basic.forever(() => {
    pins.servoWritePin(AnalogPin.P0, pins.map(
        input.lightLevel(),
        0,
        255,
        30,
        150
    ))
})

~button /projects/coffee-cup-monster/connect

NEXT: Connect

~