Hello, let’s try the compass on the micro:bit today! A digital compass is an input sensor that detects magnetic fields. Your BBC micro:bit has an inbuilt compass that can detect the direction in which it is facing. I am going to make a mine clearance alarm project today.
Firstly let’s have a look at where the compass stays on the micro:bit:
Actually, the compass could be regarded as a module to measure the magnetic field strength in various directions. The magnetic field strength can be understood as the attractive force of the magnets we usually play with. And of course, it could tell us the directions. Now let’s try our gameplay today.
Detect if there is any magnetic hidden somewhere, if yes, program to display a sad face or display a happy face.
Materials required:
Firstly, judge the magnitude of the magnetic field, if it is bigger than a certain value, execute the program in the module. Here I set the value to 400. You could change this value to adapt the sensitivity of the measurement.
Here judge if the magnitude is over 400. If yes, set to display a sad face; or with a happy one.
You can try hiding the magnet and use our micro:bit to easily find the position of the magnet!
If you have any ideas or opinions, please feel free to contact us via [email protected].