pxt-calliope/docs/lessons/night-light/quiz-answers.md

59 lines
1.1 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# night light quiz answers
2016-04-02 01:22:47 +02:00
Answers to the night light quiz.
2016-03-26 00:47:20 +01:00
2016-04-13 17:27:45 +02:00
This is the answer key for the [night light quiz](/lessons/night-light/quiz).
2016-03-26 00:47:20 +01:00
## 1. Define the function "set brightness"
This function sets the brightness of the LED screen.
## 2. Consider the following image
![](/static/mb/lessons/night-light-0.png)
If the rectangle above represents the @boardname@, write the code to set all the LEDs to full brightness and to turn on all the LEDs.
2016-03-26 00:47:20 +01:00
<br />
2016-03-31 00:54:19 +02:00
```blocks
2016-03-26 00:47:20 +01:00
led.setBrightness(255)
2016-03-31 00:54:19 +02:00
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
2016-03-26 00:47:20 +01:00
```
## 3. Consider the following image
![](/static/mb/lessons/night-light-1.png)
If the rectangle above represents the @boardname@, write the code to set the screen brightness to 50% (128) and turns on all the LEDs.
2016-03-26 00:47:20 +01:00
<br/>
2016-03-31 00:54:19 +02:00
```blocks
2016-03-26 00:47:20 +01:00
led.setBrightness(128)
2016-03-31 00:54:19 +02:00
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
2016-03-26 00:47:20 +01:00
```
## 4. Consider the following image
![](/static/mb/lessons/night-light-2.png)
If the rectangle above represents the @boardname@, write the code to turn off all the LEDs.
2016-03-26 00:47:20 +01:00
2016-03-31 00:54:19 +02:00
```blocks
2016-03-26 00:47:20 +01:00
led.setBrightness(0)
```