An accelerometer is a sensor that measures the gravitational forces pulling on it in all three dimensions of the
chip's X, Y and Z axes.
Visualization of a Common Accelerometer (ADXL345) with Three Axes
Accelerometers are devices that measure acceleration, which is the rate of change of the velocity of an object.
They measure in meters per second squared (m/s2) or in G-forces (g). A single G-force for us here on planet Earth
is equivalent to 9.8 m/s2, but this does vary slightly with elevation (and will be a different value on different planets
due to variations in gravitational pull). Accelerometers are useful for sensing vibrations in systems or for orientation
applications. Vibration is what we are looking for!
Hardware Hookup
You have had the hardware hooked up the whole time! It is on the micro:bit! Feel free to move on.
Running Your Script
Be sure to add the moto:bit package as instructed in the Installing the moto:bit Package in MakeCode section of
this tutorial.
Now, you can either download the following example script below and drag and drop it onto your micro:bit, or use it
as an example and build it from scratch in MakeCode.
onGesture(Gesture.ThreeG, () => {
tobit.setMotorSpeed(Motor.Left, MotorDirection.Reverse, 100)
tobit.setMotorSpeed(Motor.Right, MotorDirection.Reverse, 100)
onGesture(Gesture.ScreenDown, () => {
tobit.enable(MotorPower.Off)
onGesture(Gesture.ScreenUp, () => {
tobit.enable(MotorPower.On)
No Results
Microsoft MakeCode Terms of Use Privacy
Download
Edit
Simulator
Blocks
JavaScript
This site uses cookies for analytics, personalized content and ads. By continuing to
browse this site, you agree to this use.