added compass
This commit is contained in:
parent
27f39b4458
commit
d1f314d790
@ -2,32 +2,44 @@
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## [Flashing Heart](/projects/flashing-heart)
|
||||
|
||||

|
||||

|
||||
|
||||
## [Smiley Buttons](/projects/smiley-buttons)
|
||||
|
||||

|
||||

|
||||
|
||||
## [Love Meter](/projects/love-meter)
|
||||
|
||||

|
||||

|
||||
|
||||
## [Rock Paper Scissors](/projects/rock-paper-scissors)
|
||||
|
||||

|
||||
|
||||
## [Compass](/projects/compass)
|
||||
|
||||

|
||||
|
||||
## Music
|
||||
|
||||

|
||||
|
||||
## Conductive
|
||||
|
||||

|
||||
|
||||
## Network
|
||||
|
||||

|
||||
|
||||
## Radio
|
||||
|
||||

|
||||
|
||||
## Watch
|
||||
|
||||

|
||||
|
||||
|
||||
|
83
docs/projects/compass.md
Normal file
83
docs/projects/compass.md
Normal file
@ -0,0 +1,83 @@
|
||||

|
||||
|
||||
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
|
||||
|
||||

|
||||
|
||||
### ~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…
x
Reference in New Issue
Block a user