Digital Level project question.

Hi all, I’m pretty new here.
I just played around with my digital level project that I got from here
I’m using Arduino Nano and MPU 6050.
I’ve adapted the code to make it suit my application.

My questions is this. I’m thinking to add 2 buttons in my circuit. The first one is to toggle the LED’s brightness (100% 50% and 25%). The second one is to calibrate and set a new zero (degree).
How and what I have to do to achieve that.

spirit level using arduino.png

Code attached here

Here’s the code (as of now).pdf (37.3 KB)

Please post the code here or if it is too big attach it to a new post

See [read this before posting a programming question/url which is a sticky post at the top of the thread list

How and what I have to do to achieve that.

You use your favorite text editor, and start typing code that makes sense.

The state change detection example shows how to count the times that a switch becomes pressed, or becomes released. Using the count of presses, and the modulo operator (%) would make it easy to change the value in the variable that controls the brightness of the LED(s). Assuming that you CAN control the brightness.

Posting your code as a pdf file just guarantees that no one will read it. It's text. Don't embed a text file in some other format. Just post the text.

As for zeroing the device, there must be some means of calibration being used now. Triggering that again should be easy. But, I can't see your code.