Magnetic Force

Find the amount of magnetic force (the strength of a magnet) in the direction you say.

input.magneticForce(Dimension.X);

The Calliope mini measures magnetic force with microteslas.

Parameters

Returns

Example: metal detector

This program makes the center LED of the Calliope mini get brighter when the magnetic force is stronger, and dimmer when it is weaker.

led.plot(2, 2)
basic.forever(() => {
    let f = input.magneticForce(Dimension.X)
    led.setBrightness(f / 2000)
})

See also

compass heading

Edit this page on GitHub