pxt-calliope/docs/lessons/compass.md

46 lines
1.3 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# compass lesson
2017-03-29 15:36:02 +02:00
Create a compass on the @boardname@.
2016-03-26 00:47:20 +01:00
## Topic
If (Conditionals)
## Quick Links
2016-04-13 17:27:45 +02:00
* [activity](/lessons/compass/activity)
* [challenges](/lessons/compass/challenges)
* [quiz](/lessons/compass/quiz)
* [quiz answers](/lessons/compass/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 compass with If statements, Forever, Variables, Assignment Operator, Comparison Operator, Show String, and Show LEDs
## Documentation
2016-04-05 07:33:13 +02:00
```cards
2016-03-30 00:59:00 +02:00
input.compassHeading()
basic.forever(() => {})
let x = 0
if (true) {}
basic.showString("Hello!")
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
```
2016-03-26 00:47:20 +01:00
## Objectives
* learn how to run code when the @boardname@ is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
2016-03-26 00:47:20 +01:00
* 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