fixed compass error
Compass example has error in direction detect. It will get wrong result if you write it to micro:bit. And I also fixed degree between 315-359.
This commit is contained in:
parent
b6c778065f
commit
3fe18bc5fb
@ -37,15 +37,20 @@ that means whether the @boardname@ is facing north (N), south (S),
|
||||
east (E), or west (W).
|
||||
|
||||
```blocks
|
||||
let degrees = 0
|
||||
basic.forever(() => {
|
||||
let 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")
|
||||
degrees = input.compassHeading()
|
||||
if (degrees < 45) {
|
||||
basic.showArrow(ArrowNames.North)
|
||||
} else if (degrees < 135) {
|
||||
basic.showArrow(ArrowNames.West)
|
||||
} else if (degrees < 225) {
|
||||
basic.showArrow(ArrowNames.South)
|
||||
} else if (degrees < 315) {
|
||||
basic.showArrow(ArrowNames.East)
|
||||
} else {
|
||||
basic.showArrow(ArrowNames.North)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user