Spirit level

In this project, we will use a micro:bit to measure tilt - like a spirit level does with its bubble:
The micro:bit has a built-in accelerometer (just like a phone). This measures tilt, in any direction.

Code

Try this code to see what happens when you download to a real micro:bit:
Credit: micromag
The code first records the acceleration in the reading variable. 
Next we see how big reading is - when it is a small number (between -20 and +20) then we display “-”. 

Here are some photos - tilting right, and then level:
Tilting right
Level

Options

  • Try seeing how much tilt you need to get the display showing tilted (“L” or “R”).
  • Could you make it more accurate?
  • Use the accelerometer to measure vibration. Leave the microbit on a flat surface - it will display acceleration every 2 seconds. Here is the code:




Comments

Popular posts from this blog

A better Real Time Clock

Low-cost solar power source for microbits

NFC with a microbit