fixed compass bug

This commit is contained in:
Peli de Halleux 2017-03-29 06:47:52 -07:00
parent b3ad4e5b4d
commit a2a28391d0
4 changed files with 14 additions and 43 deletions

View File

@ -25,12 +25,12 @@ basic.forever(() => {
})
```
If `degrees` is less than `45`, then the compass heading is mostly pointing toward North. Display `N` on the @boardname@.
If `degrees` is less than `45` or greater than `315`, then the compass heading is mostly pointing toward North. Display `N` on the @boardname@.
```blocks
basic.forever(() => {
let degrees = input.compassHeading();
if (degrees < 45) {
if (degrees < 45 || degrees > 315) {
basic.showString("N");
}
});
@ -42,7 +42,7 @@ If `degrees` is less than 135, the @boardname@ is mostly pointing East. Display
```blocks
basic.forever(() => {
let degrees = input.compassHeading();
if (degrees < 45) {
if (degrees < 45 || degrees > 315) {
basic.showString("N");
}
else if (degrees < 135) {
@ -57,7 +57,7 @@ If `degrees` is less than 225, the @boardname@ is mostly pointing South. Display
```blocks
basic.forever(() => {
let degrees = input.compassHeading();
if (degrees < 45) {
if (degrees < 45 || degrees > 315) {
basic.showString("N");
}
else if (degrees < 135) {
@ -70,12 +70,12 @@ basic.forever(() => {
```
If none of these conditions returned true, then the @boardname@ must be pointing West. Display `W` on the @boardname@.
If none of these conditions are true, then the @boardname@ must be pointing West. Display `W` on the @boardname@.
```blocks
basic.forever(() => {
let degrees = input.compassHeading();
if (degrees < 45) {
if (degrees < 45 || degrees > 315) {
basic.showString("N");
}
else if (degrees < 135) {

View File

@ -7,10 +7,9 @@ Display the direction that the @boardname@ is facing using the compass
Complete the following [guided tutorial](/lessons/compass/activity), your code should look like this:
```blocks
let degrees = 0;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
let degrees = input.compassHeading();
if (degrees < 45 || degrees > 315) {
basic.showString("N");
}
else if (degrees < 135) {
@ -30,10 +29,9 @@ basic.forever(() => {
Instead of displaying `N` when the @boardname@ is pointing North, display a star to indicate the north star.
```blocks
let degrees = 0;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
let degrees = input.compassHeading();
if (degrees < 45 || degrees > 315) {
basic.showLeds(`
# . # . #
. # # # .
@ -61,10 +59,9 @@ basic.forever(() => {
Instead of displaying just `N`, `W`, `S`, or `E`, display the full word.
```blocks
let degrees = 0;
basic.forever(() => {
degrees = input.compassHeading();
if (degrees < 45) {
let degrees = input.compassHeading();
if (degrees < 45 || degrees > 315) {
basic.showString("NORTH");
}
else if (degrees < 135) {

View File

@ -27,28 +27,7 @@ let degrees = input.compassHeading()
```blocks
let degrees = input.compassHeading()
if (degrees < 45) {
if (degrees < 45 || degrees > 315) {
basic.showString("N", 150)
}
```
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the @boardname@
```blocks
let degrees = input.compassHeading()
if (degrees < 135) {
basic.showString("E", 150)
}
```
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the @boardname@
```blocks
let degrees = input.compassHeading()
if (degrees < 225) {
basic.showString("S", 150)
}
```

View File

@ -18,9 +18,4 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the @boardname@
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the @boardname@
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the @boardname@