How to Create Compass on micro:bit

Updated: Mar 4

Following are the steps for create Compass

  1. Click this link https://microbit.org/

  2. Then click on official code editor Microsoft Make Code to do programming

  3. Then click on New Project and give project name as Compass then this window will display


4. First remove on start block from editor workplace then click on variables and make a variable named degree and place the set degree to forever block and from input drag and drop compass heading and place it into the set degree bolck


 
 

5. If degree is less then 45, then the compass heading is mostly pointing towards North



6. click (+) to have a else if block and If degree is less then 135, then the compass heading is mostly pointing towards East



7. click (+) to have a else if block and If degree is less then 225, then the compass heading is mostly pointing towards South



8. click (+) to have a else if block and If degree is less then 315, then the compass heading is mostly pointing towards West



9. If none of these condition returned true, then the micro:bit must be pointing North again.




10. if you have a micro:bit connected into a laptop/ pc/ mobile using USB then , Click on download button and transfer your code ( hex file) to the micro:bit and see the result.


11. Move the micro:bit in any direction to get the East / West / North / South direction


Result:


North Direction:

South Dire





//video


14 views0 comments