2016-03-26 00:47:20 +01:00
|
|
|
# speed button quiz
|
|
|
|
|
2016-04-02 01:22:47 +02:00
|
|
|
counter that keeps track of how many times button "A" has been pressed.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
## Name
|
|
|
|
|
|
|
|
## Directions
|
|
|
|
|
2016-04-13 17:27:45 +02:00
|
|
|
Use this activity document to guide your work in the [speed button tutorial](/lessons/speed-button/activity).
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
|
|
|
|
|
|
|
## 1. What is a variable?
|
|
|
|
|
|
|
|
## 2. Draw which LEDs show the number being stored as a global variable called count
|
|
|
|
|
2016-03-31 01:43:56 +02:00
|
|
|
```blocks
|
2016-03-26 00:47:20 +01:00
|
|
|
let count = 0
|
|
|
|
```
|
|
|
|
|
|
|
|
![](/static/mb/empty-microbit.png)
|
|
|
|
|
|
|
|
## 3. Draw which LED is ON after running this code and pressing Button A twice. Explain why you chose to draw that number
|
|
|
|
|
2016-03-31 01:43:56 +02:00
|
|
|
```blocks
|
2016-03-26 00:47:20 +01:00
|
|
|
let count_ = 0
|
2016-03-30 06:17:57 +02:00
|
|
|
input.onButtonPressed(Button.A, () => {
|
2016-03-26 00:47:20 +01:00
|
|
|
count_ = count_ + 1
|
|
|
|
basic.showNumber(count_, 100)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
![](/static/mb/empty-microbit.png)
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
## 4. Draw which LED is ON after running this code and pressing Button A five times. Explain why you chose to draw that number.
|
|
|
|
|
2016-03-31 01:43:56 +02:00
|
|
|
```blocks
|
2016-04-01 02:38:43 +02:00
|
|
|
let count_ = 0
|
2016-03-30 06:17:57 +02:00
|
|
|
input.onButtonPressed(Button.A, () => {
|
2016-03-26 00:47:20 +01:00
|
|
|
count_ = count_ + 1
|
|
|
|
basic.showNumber(count_, 100)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
![](/static/mb/empty-microbit.png)
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|