Arduino Project
Arduino Tilt Switch LED Project V3
Course Introduction
This Arduino project uses an MPU6050 sensor to control two arrays of LEDs, showing the board’s tilt direction and angle in real time.
Red LEDs light up as the board tilts left, while blue LEDs light up as it tilts right. The tilt angle is calculated from accelerometer data, and LEDs activate step by step for every ~7° beyond a small dead zone near 0°.
This creates a clear visual indicator of orientation, with live angle values also printed to the serial monitor.
Note
If this is your first time working with an Arduino project, we recommend downloading and reviewing the basic materials first.
1.1 Install Arduino IDE(Important)
1.2 Introduction of Arduino IDE
Wiring

Common Connections:
BLUE LED
Connect the LEDs cathode to a 1kΩ resistor then to the negative power bus on the breadboard, and the LEDs anode to 2 to 7 on the Arduino.
RED LED
Connect the LEDs cathode to a 1kΩ resistor then to the negative power bus on the breadboard, and the LEDs anode to 8 to 13 on the Arduino.
MPU6050
SDA: Connect to SDA on the Arduino.
SCL: Connect to SCL on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.
Writing the Code
Note
You can copy this code into Arduino IDE.
To install the library, use the Arduino Library Manager and search for MPU6050 and install it.
Don’t forget to select the board(Arduino UNO R3) and the correct port before clicking the Upload button.
