pxt-calliope/docs/lessons/night-light/challenges.md
Abhijith Chatra be7858cbed
Cherry picked fixes from v0 to v1 ()
* Fix example and do a few edits ()

* Small fixes to the Karel project text ()

* fix missing shadow type

* add calibration info ()

microbit-support:6348 User reported bug, but didn't realie micro:bit compass had to be calibrated on first run of the program.

* Cherry pick adding various cross-editor compat APIs ()

* fix nudge

* Fix a typo ("screent") in the documentation ()

* Fix a typo
"screent" -> "the LED screen"

* Update showArrow doc string for consistency with other methods

* Doc bugs found by xlators ()

* Update rotation.md ()

reflects actual behaviour of the board

* fixed layout corruption ()

* Updating the new bug filer with the right link

* Update challenges.md ()

For what I'm taught in school, 2 follows 1 😉😉.

* Update simulator.md ()

* Update plant watering.md ()

the connection to servo are male not female

* support for MIDI simulator in v0 ()

* Doc improvements ()

* update grammar in radio-dashboard sample code

* Chanllenge 2 follows 1

I open all challenges.md without "Challenge 2" and review the file
`grep -r "Challenge 2" -L | grep challenge | xargs -I@ code @`

Changes to be committed:
	modified:   docs/lessons/counter/challenges.md
	modified:   docs/lessons/game-counter/challenges.md
	modified:   docs/lessons/night-light/challenges.md
	modified:   docs/lessons/snowflake-fall/challenges.md

* Revert "support for MIDI simulator in v0 ()"

This reverts commit 30a9c411fb80762656e7a636feff8e77b7fd9e67.

* Revert "Cherry pick adding various cross-editor compat APIs ()"

This reverts commit 7308dbef23e9ee402bebb7e721d7014d8252c9e5.

* Fixed pin needed to replace button A ()

* Cherry pick part of the signature update in in2cWriteBuffer (): 7308dbe
2018-10-22 10:00:57 -07:00

998 B

night light challenges

Coding challenges for night light.

Before we get started

Complete the following guided tutorial, your code should look like this:

led.setBrightness(255)
basic.showLeds(`
    # # # # #
    # # # # #
    # # # # #
    # # # # #
    # # # # #
    `)
input.onButtonPressed(Button.A, () => {
    led.setBrightness(64)
})

Challenge 1

What if we want to turn off all the LEDs? Let's do this by setting the brightness to 0 when button B is pressed. Add an event handler with on button pressed(B) add set brightness(0) to turn off the LEDs.

led.setBrightness(255)
basic.showLeds(`
    # # # # #
    # # # # #
    # # # # #
    # # # # #
    # # # # #
    `)
input.onButtonPressed(Button.A, () => {
    led.setBrightness(64)
})
input.onButtonPressed(Button.B, () => {
    led.setBrightness(0)
})

Challenge 2

Add an event handler with on shake to change the LED brightness back to a 255.