This commit is contained in:
Peli
2019-12-16 21:27:13 -08:00
4 changed files with 31 additions and 28 deletions

View File

@ -30,4 +30,4 @@ input.onButtonPressed(Button.AB, () => {
## See also ## See also
[compassHeading](/reference/input/compass-heading) [compass heading](/reference/input/compass-heading)

View File

@ -56,10 +56,11 @@ basic.forever(() => {
## Calibration ## Calibration
Every time you start to use the compass (for example, if you have just Every time you start to use the compass (for example, if you have just turned the @boardname@ on),
turned the @boardname@ on), the @boardname@ will start to [calibrateCompass](/reference/input/calibrate-compass) the @boardname@ will start a [calibrate compass](/reference/input/calibrate-compass)
(adjust itself). It will ask you to draw a circle by tilting the (adjust itself).
@boardname@. The [calibration step](https://support.microbit.org/support/solutions/articles/19000008874-calibrating-the-micro-bit-compass)
will ask you to draw a fill pattern on the screen by tilting the @boardname@.
If you are calibrating or using the compass near metal, it might If you are calibrating or using the compass near metal, it might
confuse the @boardname@. confuse the @boardname@.
@ -78,4 +79,4 @@ input.onButtonPressed(Button.AB, () => {
## See also ## See also
[acceleration](/reference/input/acceleration), [calibrateCompass](/reference/input/calibrate-compass) [acceleration](/reference/input/acceleration), [calibrate compass](/reference/input/calibrate-compass)

View File

@ -1,6 +1,6 @@
# Magnetic Force # Magnetic Force
Find the amount of magnetic force (the strength of a magnet) in the direction you say. Find the amount of magnetic force (the strength of a magnet) in one of the three directions.
```sig ```sig
input.magneticForce(Dimension.X); input.magneticForce(Dimension.X);
@ -10,12 +10,14 @@ input.magneticForce(Dimension.X);
The @boardname@ measures magnetic force with **microteslas**. The @boardname@ measures magnetic force with **microteslas**.
## ~ You are asked to [calibrate](https://support.microbit.org/support/solutions/articles/19000008874-calibrating-the-micro-bit-compass) the compass the first time run a program
that uses the compass.
## ~
## Parameters ## Parameters
* ``dimension`` means which direction the @boardname@ should measure * **dimension**: this is the direction the @boardname@ should measure
magnetic force in: either `Dimension.X` (the left-right direction), magnetic force in: either `Dimension.X` (the left-right direction),
`Dimension.Y` (the forward/backward direction), or `Dimension.Z` `Dimension.Y` (the forward/backward direction), or `Dimension.Z`
(the up/down direction) (the up/down direction)
@ -24,16 +26,14 @@ The @boardname@ measures magnetic force with **microteslas**.
* a [number](/types/number) of microteslas that means the strength of the magnet * a [number](/types/number) of microteslas that means the strength of the magnet
## Example: metal detector ## Example
This program makes the center LED of the @boardname@ get brighter when Create a metal detector my measuring the strength of magnetic force in the `X` direction.
the magnetic force is stronger, and dimmer when it is weaker. Display a bar graph to show the current level of magnetic force measured by the magnetometer.
```blocks ```blocks
led.plot(2, 2) basic.forever(function() {
basic.forever(() => { led.plotBarGraph(input.magneticForce(Dimension.X) / 2000, 0)
let f = input.magneticForce(Dimension.X)
led.setBrightness(f / 2000)
}) })
``` ```

View File

@ -1,18 +1,20 @@
{ {
"packages": { "packages": {
"approvedRepos": [ "approvedRepos": [
"Microsoft/pxt-neopixel", "microsoft/pxt-neopixel",
"Microsoft/pxt-microturtle", "microsoft/pxt-microturtle",
"Microsoft/pxt-sonar", "microsoft/pxt-sonar",
"Microsoft/pxt-hacking-stem", "microsoft/pxt-hacking-stem",
"Microsoft/pxt-bluetooth-temperature-sensor", "microsoft/pxt-bluetooth-temperature-sensor",
"Microsoft/pxt-bluetooth-midi", "microsoft/pxt-bluetooth-midi",
"Microsoft/pxt-max6675", "microsoft/pxt-max6675",
"Microsoft/pxt-midi", "microsoft/pxt-midi",
"Microsoft/pxt-radio-blockchain", "microsoft/pxt-radio-blockchain",
"Microsoft/pxt-bluetooth-max6675", "microsoft/pxt-bluetooth-max6675",
"Microsoft/pxt-filesystem", "microsoft/pxt-filesystem",
"Microsoft/pxt-ws2812b", "microsoft/pxt-ws2812b",
"microsoft/pxt-apa102",
"microsoft/pxt-radio-firefly",
"KitronikLtd/pxt-kitronik-servo-lite", "KitronikLtd/pxt-kitronik-servo-lite",
"KitronikLtd/pxt-kitronik-motor-driver", "KitronikLtd/pxt-kitronik-motor-driver",
"KitronikLtd/pxt-kitronik-I2C-16-servo", "KitronikLtd/pxt-kitronik-I2C-16-servo",