Migrate docs from the other repo

This commit is contained in:
Michal Moskal
2016-03-25 16:47:20 -07:00
parent 38d2cf06d2
commit a08eb53f92
895 changed files with 36888 additions and 0 deletions

View File

@ -0,0 +1,102 @@
# compass activity
Display the direction that the micro:bit is facing using the compass
### ~avatar avatar
Welcome! This guided tutorial will show you how to program a script that displays the direction the micro:bit is pointing. Let's get started!
### ~
Create a loop that will continuously update the reading of the compass.
```blocks
basic.forever(() => {
})
```
Store the reading of the micro:bit in a variable called `degrees`.
```blocks
basic.forever(() => {
let degrees = input.compassHeading()
})
```
If `degrees` is less than `45`, then the compass heading is mostly pointing toward North. Display `N` on the micro:bit.
```blocks
let degrees = 0;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
});
```
If `degrees` is less than 135, the micro:bit is mostly pointing East. Display `E` on the micro:bit.
```blocks
let degrees = null;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
else if (degrees < 135) {
basic.showString("E");
}
});
```
If `degrees` is less than 225, the micro:bit is mostly pointing South. Display `S` on the micro:bit.
```blocks
let degrees = null;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
else if (degrees < 135) {
basic.showString("E");
}
else if (degrees < 225) {
basic.showString("S");
}
});
```
If none of these conditions returned true, then the micro:bit must be pointing West. Display `W` on the micro:bit.
```blocks
let degrees = null;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
else if (degrees < 135) {
basic.showString("E");
}
else if (degrees < 225) {
basic.showString("S");
}
else {
basic.showString("W");
}
});
```
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/microbit/lessons/compass/challenges)!
### ~

View File

@ -0,0 +1,88 @@
# compass challenges
Display the direction that the micro:bit is facing using the compass
## Before we get started
Complete the following [guided tutorial](/microbit/lessons/compass/activity), your code should look like this:
```blocks
let degrees = null;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
else if (degrees < 135) {
basic.showString("E");
}
else if (degrees < 225) {
basic.showString("S");
}
else {
basic.showString("W");
}
});
```
### Challenge 1
Instead of displaying `N` when the BBC micro:bit is pointing North, display a star to indicate the north star.
```blocks
let degrees = null;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
basic.showLeds(`
# . # . #
. # # # .
# # # # #
. # # # .
# . # . #`);
}
else if (degrees < 135) {
basic.showString("E");
}
else if (degrees < 225) {
basic.showString("S");
}
else {
basic.showString("W");
}
});
```
* Run your code to see if it works as expected
### Challenge 2
Instead of displaying just `N`, `W`, `S`, or `E`, display the full word.
```blocks
let degrees = null;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("NORTH");
}
else if (degrees < 135) {
basic.showString("EAST");
}
else if (degrees < 225) {
basic.showString("SOUTH");
}
else {
basic.showString("WEST");
}
});
```
* Run your code to see if it works as expected
### Challenge 3
Display your own unique message for each direction.

View File

@ -0,0 +1,56 @@
# compass quiz answers
Create an actual compass to show your direction: North, South, East, or West
## Name
## Directions
Use this activity document to guide your work in the [compass tutorial](/microbit/lessons/compass/activity).
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. What is the purpose of the 'compass heading' block?
Gets the compass heading of the micro:bit in degrees
<br/>
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
<br/>
```
let degrees = input.compassHeading()
```
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the micro:bit
<br />
```
if (degrees < 45) {
basic.showString("N", 150)
}
```
## 3. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the micro:bit
<br />
```
if (degrees < 135) {
basic.showString("E", 150)
}
```
## 3. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the micro:bit
<br />
```
if (degrees < 225) {
basic.showString("S", 150)
}
```

View File

@ -0,0 +1,32 @@
# compass quiz
Create an actual compass to show your direction: North, South, East, or West
## Name
## Directions
Use this activity document to guide your work in the [compass activity](/microbit/lessons/compass/activity).
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. What is the purpose of the 'compass heading' block?
<br/>
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
<br/>
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the micro:bit
<br />
## 3. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the micro:bit
<br />
## 3. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the micro:bit
<br />