# Need help at coding

**URL:** <https://forum.arduino.cc/t/need-help-at-coding/1250376>\
**Category:** Programming\
**Created:** [April 21, 2024, 1:15pm UTC](https://forum.arduino.cc/t/need-help-at-coding/1250376 "2024-04-21T13:15:02Z")\
**Posts on this page:** 1\
**Showing post:** 45

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [April 26, 2024, 6:16am UTC](https://forum.arduino.cc/t/need-help-at-coding/1250376/45 "2024-04-26T06:16:49Z")

</div>

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:

1. reading in the MPU-values
2. 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

> [@Example-code for timing based on millis() easier to understand through the use of example-numbers / avoiding delay()](https://forum.arduino.cc/t/example-code-for-timing-based-on-millis-easier-to-understand-through-the-use-of-example-numbers-avoiding-delay/974017/1):
>
> non-blocking timing. Execute code only from time to time. There are a lot of different ways to learn programming. This thread wants to add another approach that is different to the yet existing ones. UPDATE 06.01.2023 if you are mainly interested in applying non-blocking timing you can do a quick read of this short tutorial / demonstration If you are intersted in understanding the details how it works go on reading here. I use an everyday analogon in this post to explain the basic principle …

It is a **crucial pre-condition** to understand the basic principle how non-blocking timing works to proceed.

---

_[View the full topic](https://forum.arduino.cc/t/need-help-at-coding/1250376)._
