You should stop investing time into apologising and start real learning.
You seem to stuff together code-fragments that you find online without understanding them.
You did not write when you started this project. Until 2. May there are 5 days left.
If you go on stuffing things together in hoping that it will work it is very unlikely that this method will be successfull right in time.
To draw a picture that shall explain it:
Your trying to make it work is like
you can ride a normal bike but have no experience with BMX-freestyle artistic biking. And now you are trying to do BMX-freestyling riding a half-pipe trying to ride saltos.
You can go on for 5 days trying again and again riding saltos using different half-pipes. This will not work.
You should practise more easy things for 2 or 3 days like jumps over a ramp without salto. To get the feeling for the BMX-bike and your body.
And after that starting practising saltos.
But you seem to be in a fear you won't finish it and keep waisting time by trying to practise saltos. For which it is very sure if you do this as the first step it will surely not work.
Me personal I will NEVER post ready to use code.
I will support learning.
Your code can be divided into the following parts:
- reading in the MPU-values
- checking if it is
a. NOT tilt to the left nor to the right
b. tilt to the left
c. tilt to the right
which is a three-part checking.
-
reading in the hall-sensor with setting the boolean flag
-
checking the boolean flag "hall-sensor beeing triggered" or not
and in case it is triggered stop tilt-animation immidiately -
show "STOP" on the display.
Terminating the tilt animation immidiately means to replace ALL for-loops in the animation with a non-blocking way of executing the code.
To able to do this you have to LEARN and UNDERSTAND non-blocking timing.
My offer is to support your learning. You have to decide either following this way or going on in the way you worked before but without my support.
This is a tutorial that explains non-blocking timing
It is a crucial pre-condition to understand the basic principle how non-blocking timing works to proceed.