The Calliope mini measures magnetic force with microteslas.
Find the amount of magnetic force (the strength of a magnet) in the direction you say.
input.magneticForce(Dimension.X);
dimension
means which direction the Calliope mini should measure
magnetic force in: either Dimension.X
(the left-right direction),
Dimension.Y
(the forward/backward direction), or Dimension.Z
(the up/down direction)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)
})