Arduino Project

Arduino Tilt Switch LED Project V2

Course Introduction

This project controls an array of LEDs based on the tilt angle detected by an MPU6050 sensor.

The LEDs illuminate in response to X-axis tilt, visually indicating the board’s orientation.

Tilt angles are continuously calculated from acceleration data provided by the MPU6050, and corresponding LEDs activate according to predefined angle thresholds.

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

Required Components

In this project, we need the following components:

SN

COMPONENT INTRODUCTION

QUANTITY

PURCHASE LINK

1

Arduino UNO R4

1

2

USB Type-C cable

1

×

3

Breadboard

1

BUY

4

Wires

Several

5

1kΩ resistor

Several

6

LED

Several

7

MPU6050 Module

1

Wiring

5.webp__PID:0c0459d8-c0ec-4b5e-b80c-73b4ac552223

Common Connections:

LED
Connect the LEDs anode to a 1kΩ resistor then to the negative power bus on the breadboard, and the LEDs cathode 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.