Tilt from the accelerometer
An ADXL345 spirit level from the gallery: turn counts into degrees with asin and atan2, work out how many degrees its dead band is, and tighten it to one degree.
Open it in the simulatorWhat a motion sensor really measures: gravity as a vector, tilt from atan2, gyro drift and calibration, the complementary filter, a magnetometer compass, step and tap detection, and a tilt-compensated level and compass.
0 of 7 done
7 lessons in 4 chapters, about 6 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.
An ADXL345 spirit level from the gallery: turn counts into degrees with asin and atan2, work out how many degrees its dead band is, and tighten it to one degree.
Open it in the simulatorOne line of code that keeps the gyro’s smoothness and the accelerometer’s honesty. Measure what is left of the drift, shove the board and see the filter shrug, follow a real tilt, and change its time constant.
Open it in the simulatorTurn a stream of accelerometer numbers into events: a step counter with two thresholds and a lockout, cadence in steps a minute, and a tap and double-tap detector that looks for a jump between two samples.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
An accelerometer measures gravity as a vector: three numbers, raw counts, and the angle they hide.
Read an MPU6050 straight from its registers and watch 1 g of gravity split across three axes as you tip it. Predict each number with sines and cosines, read the raw counts, and find the one thing an accelerometer cannot tell apart.
0 of 6 steps
An ADXL345 spirit level from the gallery: turn counts into degrees with asin and atan2, work out how many degrees its dead band is, and tighten it to one degree.
0 of 6 steps
A gyro added up into an angle, the drift that comes with it, and the one-line filter that fixes it.
Add up a gyroscope into an angle and watch it walk away: a real gyro’s 0.4 degrees a second of offset, added in the sketch. Predict when it is 2 degrees off, measure the offset at rest, subtract it, and see the gyro follow a real tilt.
0 of 6 steps
One line of code that keeps the gyro’s smoothness and the accelerometer’s honesty. Measure what is left of the drift, shove the board and see the filter shrug, follow a real tilt, and change its time constant.
0 of 6 steps
A magnetometer compass and its traps, then a stream of readings turned into steps and taps.
An LIS3MDL magnetometer and an LSM6DSOX from the gallery: a compass heading from atan2, the turn rate from the gyro, why tipping a compass throws it off by tens of degrees, and true north from declination.
0 of 6 steps
Turn a stream of accelerometer numbers into events: a step counter with two thresholds and a lockout, cadence in steps a minute, and a tap and double-tap detector that looks for a jump between two samples.
0 of 6 steps
A builder’s level and a compass that stays true when you tip it, on an MPU-9250.
An MPU-9250 on an Uno as a builder’s level with a green and a red LED, and a compass that stays right when you tip it: gravity gives roll and pitch, and they turn the magnetic field back to level before atan2.
0 of 7 steps
All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.
Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.
Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kitYes. All 7 lessons of Accelerometers, gyros and IMUs are free and run in your browser, with nothing to install and no parts to buy before you start.
No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.
About 6 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.
Each chapter ends in a project that puts it together: Tilt from the accelerometer, The complementary filter and Step and tap detection.
With "Gravity as a vector", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.