adjustable digital spirit level

Hi
I am working on a project where I am trying to make an “adjustable digital spirit level”. I have a mpu9250 with pro mini and OLED display. I am getting the X and Y axis display on the OLED.
Aim:

  • Place the appliance at the desired angle on the platform and press the push button.
  • The angle values in X and Y axis get stored.
  • While replacing the platform, recheck the angle by placing the appliance on the platform.
  • If the angle changes more than 10 , there is a buzzer sound and LED glows. Preferably 2 LED one for X axis and One for Y axis offset.
    Need Guidance:
  1. Steps to be taken during coding.
  2. How do I go about defining a variable which stores the selected value of X and Y
  3. Do I need to execute the angle calculation code again after the push button is pressed? Or one time code is sufficient.
    I have seen a couple of code for thermostat where a specific temperature value was entered with a keypad, but have not come across a code where an certain value from the sensor is taken as a reference value .
    I am a beginner and learning the intricacies of coding, at present I rely on using codes from the internet and adapting them to my needs.
    Please guide as how I should go about this project and if there and are any examples you know of.

Your other posts on the forum suggest that you’ve already got some code.
Why not post it here?

Here is the code which I have worked on a bit. It displays the values on the OLED now i want to add the select button , LED and buzzer.

In this i have defined the button and LED now what to do and how. Explanation with example would be very helpful as mentioned earlier I am learning.

sketch_adjustable_spirit_levela.ino (8.91 KB)

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

Sorry cant do it as it gives a error message ( Post crosses the limit of 9000 characters) hence have attached the .ino file

Hi
I am working on a project where I am trying to make an “adjustable digital spirit level”. I have a mpu9250 with pro mini and OLED display. I am getting the X and Y axis display on the OLED.
Aim:

  • Place the appliance at the desired angle on the platform and press the push button.
  • The angle values in X and Y axis get stored.
  • While replacing the platform, recheck the angle by placing the appliance on the platform.
  • If the angle changes more than 10 , there is a buzzer sound and LED glows. Preferably 2 LED one for X axis and One for Y axis offset.
    Need Guidance:
  1. Steps to be taken during coding.
  2. How do I go about defining a variable which stores the selected value of X and Y
  3. Do I need to execute the angle calculation code again after the push button is pressed? Or one time code is sufficient.
    I have seen a couple of code for thermostat where a specific temperature value was entered with a keypad, but have not come across a code where an certain value from the sensor is taken as a reference value .
    I am a beginner and learning the intricacies of coding, at present I rely on using codes from the internet and adapting them to my needs.
    Please guide as how I should go about this project and if there and are any examples you know of.

Outline of the project

  1. Define: push button, Led, MPU , buzzer.
  2. Include : Libraries- U8glib.h
  • Wire.h
  1. Code for MPU to calculate X,Y Z axis value.
  2. Now what—?
    In my code the next step is printing to the serial port and Display. I want to select the values of X,Y axis displayed on the screen with the push of the button. These values will become the reference values and any deviation of more than 10 in either axis will sound the buzzer and light up the relevant LED.
    Now where do I put the - selection code,
  • If ,else condition

sketch_adjustable_spirit_levela.ino (8.91 KB)

Hi,
Why aren't you using a MPU9250 library to do your 9250 communication?

https://learn.sparkfun.com/tutorials/9dof-razor-imu-m0-hookup-guide/using-the-mpu-9250-dmp-arduino-library

Tom... :slight_smile: