In this project i will show you how to build a simple 4 led tilt dimmer with a gyroscope and an arduino uno. There are 4 leds arranged in a "+" shape and they will light up more as you tilt the breadboard.
This won't involve any soldering, just basic breadboard assembly and basic arduino programming.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials:
1) An Arduino Uno board and a USB cable. You can use a different board if you like but keep in mind that different boards have different pin configs, for example if you use an Arduino Mega the SDA and SCL pins are 20 and 21.
2) 4 leds, the leds should be identical , the color doesn't matter it's up to you :)
3) 4 identical resistors anywhere between 100 ohms and 1 K ohm, i recommend around 200
4) a breadboard
5) dupont wires
6) MPU-6050 gyro
7) U-shape jumper cables (optional). I've used these jumper cables because they look better on the breadboard, and the leds are more visible this way. You can find a box of 140 on ebay at about 4$. If you don't have these cables you can replace them with dupont wires.
Step 2: Assembly
1) Begin by placing the 4 leds on the breadboard in a "+" shape. The long pins of the leds are positive. I've placed the positive pins for the top and bottom leds on the right, and for the left and right leds below (see on the first picture.
2) Insert the four resistors in the breadboard.
3) Place the MPU6050 like in the picture
4) Insert the wires. The leds ground pins will go directly to the ground. The positive pins will go through a resistor into the arduino pins: pin 3 through a resistor to the front led, pin 5 through a resistor to the bottom led, and similar with pin 6 right led, pin 9 left led
The MPU6050 must be connected to ground and 5V+, after that connect SDA to A4 (analog 4), SCL to A5
I've also attached an fritzig schematic, if you want to make sure the connections are correct.
Step 3: The Code
Source code here: https://github.com/danionescu0/arduino/tree/master...
Or copy-paste it from below:
You will need two external libs I2CDev and MPU6050, i've attached them here, and i've posted below the source of the code. I've not written those libs it's not my merit :)
If you don't know how to install a library check this instructable:
Then copy paste or download my library and give it a try.
* I2CDev library source: https://github.com/jrowberg/i2cdevlib
Step 4: Improvements and Different Uses of the Gyro
This is the simplest project i've done with MPU6050, i can think of many derivatives from this idea:
- adding two or more leds for each direction, so the steeper the angel, the more leds will light up
- making a wearable that will warn you with a sound that you don't have a correct upright position
Those ugly conditions i think can be improved with some math (replace if's with some equations).
As a BONUS :) i've made a youtube video with another version of the project, i've added 3 leds for up, e for down, 2 for left and two for right.
If you want to check the video click here. I've also attached a picture of the breadboard above.
For those who are interested the code go here, and replace this line
#define SIMPLE_IMPLEMENTATION true ---------- with ----------- #define SIMPLE_IMPLEMENTATION false
The new led pinout is: front leds: 3,12,11, bottom leds: 5,6,7, left leds: 10, 4, right leds: 6, 9
In my other tutorial i've shown how the gyroscope can be used toflip the display on the computer when the display is physically rotated. The instructable is here.
If you liked the youtube videos, you can get more by subscribing to my channel here
Step 5: A Recent Add-on to This Tutorial, a Neopixel Ring Driven by a Gyroscope
You can find the code here if you're interested about that.
AlexR385 made it!