MPU6050 Tilt Indicator
An MPU6050, an Arduino, and three LEDs — feel the difference between accelerometer and gyro readings.
Difficulty: Breadboard. Estimated build time: about 60 minutes. Estimated parts cost: about US$7.00. 6-line bill of materials. Compare supplier offers when available. A pocket-sized motion sensor that lights one of three LEDs depending on which axis the breadboard is being tilted along.
Wire the MPU6050 breakout to the Arduino
The MPU6050 GY-521 breakout has eight through-holes, but you only need four: VCC to the Arduino's 3.3 V rail (the chip is 3.3 V native, though most breakouts include a regulator that tolerates 5 V — read your specific board), GND to GND, SDA to A4, and SCL to A5. The XDA, XCL, AD0, and INT pins stay disconnected for now. Take a moment to orient the breakout so the silkscreen arrow that marks the chip's axes points in a direction you can remember — most boards label X across the long edge and Y across the short edge.
Add the three axis LEDs
Wire three LEDs (your favourite colours) to Arduino digital pins 6, 7, and 8, each with its own 220 Ω current-limiting resistor to GND. Label them on the breadboard: X (rose), Y (amber), Z (sky). Keeping each axis a distinct colour pays off immediately when you tilt the board — your eye learns the mapping in seconds, no looking at a serial monitor required.
Install the I²Cdev + MPU6050 library and verify the connection
In the Arduino IDE Library Manager, install "MPU6050" by Electronic Cats (or Jeff Rowberg's i2cdevlib). Load the I2Cdev example sketch "MPU6050_raw" and open the serial monitor at 38400 baud — you should see six numbers updating fast (ax, ay, az, gx, gy, gz). If you get "connection failed," double-check SDA/SCL aren't swapped and that the AD0 pin is tied where the library expects (most breakouts pull it low; the I²C address is 0x68 by default, 0x69 if AD0 is tied high).
Map raw readings to gravity (g)
The accelerometer raw range is ±32 768 (signed 16-bit) and the default full-scale is ±2 g, so divide each axis by 16 384.0 to get g's. At rest, you should see one axis read close to ±1.0 g (the one pointing up or down) and the other two read close to 0 g. Tilt the board 30 degrees and you should see roughly 0.5 g on the axis that just left vertical and a complementary change on the other. This direct mapping from raw count to physical units is one of the cleanest moments in electronics — the chip really does measure gravity, and you can hold it in your hand and watch the numbers prove it.
Light the LED whose axis crosses the threshold
In the main loop, compute the three accelerometer values in g, take their absolute values, and light the corresponding LED whenever it exceeds ~0.5 g and is the largest of the three. This means the X LED lights when the board is tipped onto its side, the Y LED lights when it's tipped front-to-back, and the Z LED stays on when the board is roughly level (gravity pulls down through Z). Add a 50 ms delay between reads to keep the LEDs from flickering; that's still plenty fast for visible motion.
Try the gyroscope half and feel the difference
Now divide each gyroscope axis by 131.0 to get degrees per second. Rotate the board steadily — gx, gy, or gz should read 100–500 deg/s and snap back to zero when you stop. Try the same trick (light an LED when |gx| > 100): the gyroscope LEDs only flash WHILE you are rotating, while the accelerometer LEDs care about where the board is pointed regardless of motion. That tradeoff is why real flight controllers fuse both halves with a complementary or Kalman filter.