53 lines
1.5 KiB
Markdown
53 lines
1.5 KiB
Markdown
# compass lesson
|
|
|
|
create a die on the BBC micro:bit #button #pressed #math #random #var #string #if #docs
|
|
|
|
### @video td/videos/compass-0
|
|
|
|
## Topic
|
|
|
|
If (Conditionals)
|
|
|
|
## Quick Links
|
|
|
|
* [activity](/microbit/lessons/compass/activity)
|
|
* [challenges](/microbit/lessons/compass/challenges)
|
|
* [quiz](/microbit/lessons/compass/quiz)
|
|
* [quiz answers](/microbit/lessons/compass/quiz-answers)
|
|
|
|
## 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 compass with If statements, Forever, Variables, Assignment Operator, Comparison Operator, Show String, and Show LEDs
|
|
|
|
## Documentation
|
|
|
|
```docs
|
|
input.compassHeading()
|
|
|
|
basic.forever(() => {})
|
|
|
|
let x = 0
|
|
|
|
if (true) {}
|
|
|
|
basic.showString("Hello!")
|
|
|
|
basic.showLeds(`
|
|
. . . . .
|
|
. . . . .
|
|
. . # . .
|
|
. . . . .
|
|
. . . . .
|
|
`)
|
|
```
|
|
|
|
## Objectives
|
|
|
|
* 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
|