2016-03-26 00:47:20 +01:00
# die roll lesson
2016-04-02 01:22:47 +02:00
create a die on the BBC micro:bit.
2016-03-26 00:47:20 +01:00
### @video td/videos/die-roll-0
## Topic
If (Conditionals)
## Quick Links
2016-04-13 17:27:45 +02:00
* [activity ](/lessons/die-roll/activity )
* [challenges ](/lessons/die-roll/challenges )
* [quiz ](/lessons/die-roll/quiz )
* [quiz answers ](/lessons/die-roll/quiz-answers )
2016-03-26 00:47:20 +01:00
## Prior learning/place of lesson in scheme of work
Learn how to use an if statements to run code run code depending on whether a condition is true or not. We will be learning how to create a die with If statements, On Shake, Variables, Assignment Operator, Pick Random and Show LEDs
## Documentation
2016-04-05 07:33:13 +02:00
```cards
input.onGesture(Gesture.Shake, () => {})
2016-03-30 00:59:00 +02:00
let x = 0
2016-04-05 07:33:13 +02:00
Math.random(3)
if (true) {}
2016-03-30 00:59:00 +02:00
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
```
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
## Objectives
2016-03-26 00:47:20 +01:00
2016-03-30 00:59:00 +02:00
* learn how to run code when the BBC micro:bit is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
* learn how to create a local variable as a place where you can store and retrieve data
* learn how the assignment operator is used to declare a new local variable
* learn how to declare a new local variable or update the value of a variable
* learn how to return a random number
* learn how to conditionally run code depending on whether a condition is true or not
* learn how to show an image on the LED screen