Digital Spirit Level

Hi,

I have recently bought a starter kit and it came with an accelerometer, gy-521 ITG/MPU MPU-6050. I am trying to make a digital spirit level and display the results on the LCD screen. All I know so far is how to print something on the screen and how to get
results from the accelerometer on the serial monitor.

Is there anyone who has done this or can help me!

WIN_20160505_20_05_19_Pro (2).jpg

Assuming you are using Jeff Rowberg's MPU6050 library then you can use the MPU6050_DMP6 example as the starting point.

If you run that then the default settings in the sketch will send the yaw pitch and roll angles to the Serial Monitor window. Pick an axis that is conveniently showing values near to zero when your have your board in the desired orientation and use the appropriate ypr[] array value tilt angle (already in degrees) as the basis for your spirit level.

Modify the code to print to the LCD instead of the serial port. There is a lot of unnecessary code you could strip out as well (in the unused #ifdef sections) if you wanted to.

When you test your "level" on a horizontal surface you will probably need to either adjust the angle of the sensor slightly to zero it or add a calibration offset into your code.

Thanks,

I don't think I am using the Jeff Roebergs Library. How do I use it, or is it a downloadable library of the internet?

Have you tried something called "Google"?

Kobi_F:
Thanks,

I don't think I am using the Jeff Roebergs Library. How do I use it, or is it a downloadable library of the internet?

Download the Zip file here, inside the Zip file is a folder called Arduino, inside that is the library you need (MPU6050) install the library into your Arduino environment, the example quoted is included in the library.

Thanks!