added compass
This commit is contained in:
parent
27f39b4458
commit
d1f314d790
@ -2,32 +2,44 @@
|
||||
|
||||
![](/static/mb/projects/all10.png)
|
||||
|
||||
![](/static/mb/projects/a1-display.png)
|
||||
|
||||
## [Flashing Heart](/projects/flashing-heart)
|
||||
|
||||
![](/static/mb/projects/a2-buttons.png)
|
||||
![](/static/mb/projects/a1-display.png)
|
||||
|
||||
## [Smiley Buttons](/projects/smiley-buttons)
|
||||
|
||||
![](/static/mb/projects/a3-pins.png)
|
||||
![](/static/mb/projects/a2-buttons.png)
|
||||
|
||||
## [Love Meter](/projects/love-meter)
|
||||
|
||||
![](/static/mb/projects/a4-motion.png)
|
||||
![](/static/mb/projects/a3-pins.png)
|
||||
|
||||
## [Rock Paper Scissors](/projects/rock-paper-scissors)
|
||||
|
||||
![](/static/mb/projects/a4-motion.png)
|
||||
|
||||
## [Compass](/projects/compass)
|
||||
|
||||
![](/static/mb/projects/a5-compass.png)
|
||||
|
||||
## Music
|
||||
|
||||
![](/static/mb/projects/a6-music.png)
|
||||
|
||||
## Conductive
|
||||
|
||||
![](/static/mb/projects/a7-conductive.png)
|
||||
|
||||
## Network
|
||||
|
||||
![](/static/mb/projects/a8-network.png)
|
||||
|
||||
## Radio
|
||||
|
||||
![](/static/mb/projects/a9-radio.png)
|
||||
|
||||
## Watch
|
||||
|
||||
![](/static/mb/projects/a10-watch.png)
|
||||
|
||||
|
||||
|
83
docs/projects/compass.md
Normal file
83
docs/projects/compass.md
Normal file
@ -0,0 +1,83 @@
|
||||
![](/static/mb/projects/a5-compass.png)
|
||||
|
||||
Use the compass to determine which direction you are heading.
|
||||
|
||||
## Step 1
|
||||
|
||||
Continuously sample the compass heading and store in the variable `degrees`:
|
||||
|
||||
```blocks
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
});
|
||||
```
|
||||
|
||||
## Step 2
|
||||
|
||||
If the degrees is less than 45, we are heading North:
|
||||
|
||||
```blocks
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
if (degrees <= 45) {
|
||||
basic.showString("N");
|
||||
} else if (false) { } else { }
|
||||
});
|
||||
```
|
||||
|
||||
### Step 3
|
||||
|
||||
Otherwise, if the degrees is less than 135, we are heading East:
|
||||
|
||||
```blocks
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
if (degrees <= 45) {
|
||||
basic.showString("N");
|
||||
} else if (degrees <= 135) {
|
||||
basic.showString("E");
|
||||
} else { }
|
||||
});
|
||||
```
|
||||
|
||||
### Step 4
|
||||
|
||||
Otherwise, if the degrees is less than 225, we are heading East:
|
||||
|
||||
```blocks
|
||||
let degrees = 0;
|
||||
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 {
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Step 5
|
||||
|
||||
Otherwise, we are heading west.
|
||||
|
||||
```blocks
|
||||
let degrees = 0;
|
||||
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");
|
||||
}
|
||||
});
|
||||
```
|
@ -1,5 +1,7 @@
|
||||
# rock paper scissors
|
||||
|
||||
![](/static/mb/projects/a4-motion.png)
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
```sim
|
||||
|
BIN
docs/static/mb/projects/all10.png
vendored
BIN
docs/static/mb/projects/all10.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 102 KiB |
Loading…
Reference in New Issue
Block a user