Micro:bit Compass

by 陳亮 in Circuits > Microcontrollers

13570 Views, 42 Favorites, 0 Comments

Micro:bit Compass

ORG_DSC07210.jpg

This instructables show how to use micro:bit to make a simple digital compass.

Get a Micro:bit

ORG_DSC07201.jpg

If you not yet have a micro:bit, you may get a micro:bit here: https://microbit.org/resellers/

Optional: Battery Holder

ORG_DSC07206.jpg

If you want to make the digital compass portable, you may consider get a battery holder.

Any 3V battery holder with JST connector should be ok. The battery can be CR2032, 2 x AAA batteries, 2 x AA batteries, etc.

Optional: 3D Printed Cover

ORG_DSC07207.jpg
ORG_DSC07208.jpg

I feel direct view the SMD LED light is not so comfort, so I have made a 3D printed cover diffuse the light and make every LED like a perfect square pixel :>

If you also like the pixels, you can download and print the cover here:

https://www.thingiverse.com/thing:3511591

How Does Digital Compass Work?

microbit-overview-1-5.png

Input

micro:bit have a magnetic field sensor, just like a normal compass needle, it can sense the magnetic field produced inside Earth. micro:bit library translate the field value into 360 degrees relative to north.

Output

micro:bit have 5 x 5 LED matrix, it is good enough to show an arrow in 8 directions. (North, NE, East, SE, South, SW, West, NW)

Ref.: https://tech.microbit.org/hardware/

Note on the Magnetic Field Direction

ORG_DSC07211.jpg

Please reminded that the magnetic field sensor and the LED are placed on different side of the PCB. So when you look at the LED side the magnetic field reading is flipped. Or you can treat the reading is counter-clockwise start from North.

Angle Mapping

IMG_7121.jpg

The input is a 360 degrees value and the output is 8 directions arrow, here is the angle mapping:

 23 -  68 NW
 68 - 113 West
113 - 158 SW
158 - 203 South
203 - 248 SE
248 - 293 East
293 - 338 NE
Others    North

MakeCode

2019-03-21_145953.png

Here is my sample block code:

https://makecode.microbit.org/_RfA4jH2Rae78

Simply download and copy to micro:bit drive to run.

If you are not yet familiar with using micro:bit please read the official quick start guide first:

https://microbit.org/guide/quick/

Calibrating the Micro:bit Compass

螢幕快照 2019-03-27 上午11.43.23.png

If you are first time using the micro:bit magnetic field sensor, the LED matrix will scroll the words TILT TO FILL SCREEN.

Please follow the support page video to calibrating the micro:bit compass:

https://support.microbit.org/support/solutions/art...

Happing Coding!

IMG_7123.jpg

micro:bit compass is just a very simple example, micro:bit have much more can be done.

Let's explore more ideas here:

https://microbit.org/ideas/