How to Use Tilt Sensor with Micro:bit?
Overview
When design the circuit, sometimes you will need to test whether an object is tilted left or right, so in this case you can use our tilt sensor. In this project, you will learn how to use our digital tilt sensor to control 5*5 LED of micro:bit display different images.
Component Required:
Micro:bit main board*1
Keyestudio Micro bit Sensor V2 Shield*1
USB Cable*1
Keyestudio Digital Tilt Sensor*1
DuPont jumper wire*3
Premium Battery Holder 6-cell AA*1
1.5V AA Battery*6
Component Introduction
Tilt Sensor:
This keystudio digital tilt sensor mainly integrates a tilt sensor. The tilt sensor is a component that can detect the tilting of an object.
The principle is very simple. It mainly uses the ball in the switch changing with different angle of inclination to achieve the purpose of triggering circuits. When the ball in tilt switch runs from one end to the other end because of external force shaking, the tilt switch will conduct, or it will break.
Connection Diagram
Test Code
Test Results
Done wiring and powered up, send the code to micro:bit. When tilt the sensor to the left, you should see the LED matrix of micro:bit show the icon like a heart . If tilted to the right, it will show the icon like this
.