# Set variablr magnetic force not working

**URL:** <https://forum.makecode.com/t/set-variablr-magnetic-force-not-working/18331>\
**Category:** micro:bit\
**Created:** [March 7, 2023, 8:37pm UTC](https://forum.makecode.com/t/set-variablr-magnetic-force-not-working/18331 "2023-03-07T20:37:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grandp](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@Grandp](https://forum.makecode.com/u/Grandp)\
**Post date:** [March 7, 2023, 8:37pm UTC](https://forum.makecode.com/t/set-variablr-magnetic-force-not-working/18331/1 "2023-03-07T20:37:59Z")

</div>

Trying to do the magic button

> **[Magic Button Trick](https://makecode.microbit.org/projects/magic-button-trick)**
>
> Build a magic trick that uses the micro:bit’s compass to detect a nearby magnet!

When I use the function  
Set to magnetic force (ut)  
When I flash the code the Microbit runs a program the that display  
TILT TO FILL THE SCREEN

---

<div class="post-metadata">

**Author:** ![dsssssssss9](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dsssssssss9/32/861_2.png) [@dsssssssss9](https://forum.makecode.com/u/dsssssssss9)\
**Post date:** [March 7, 2023, 9:22pm UTC](https://forum.makecode.com/t/set-variablr-magnetic-force-not-working/18331/2 "2023-03-07T21:22:42Z")

</div>

Hi

this is to be expected

Every time you upload code containing compass functions , the magnetic sensor will need to be calibrated…

> **[How to calibrate the micro:bit compass](https://support.microbit.org/support/solutions/articles/19000008874-calibrating-the-micro-bit-compass)**
>
> The micro:bit has a built-in compass. This compass has to be calibrated the first time that it is used, so that the readings that it produces are accurate. The micro:bit compass is configured to be used in a horizontal orientation, just ...

Regards

---

<div class="post-metadata">

**Author:** ![Grandp](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@Grandp](https://forum.makecode.com/u/Grandp)\
**Post date:** [March 7, 2023, 9:56pm UTC](https://forum.makecode.com/t/set-variablr-magnetic-force-not-working/18331/3 "2023-03-07T21:56:41Z")

</div>

> [@dsssssssss9](#):
>
> [https://support.microbit.org/support/solutions/articles/19000008874-calibrating-the-micro-bit-compass](https://support.microbit.org/support/solutions/articles/19000008874-calibrating-the-micro-bit-compass)

Just to have to be patient.  
Tahnks
