There’s a lot of theory you are missing out on to get your desired results. This first is Dead-Band. Most controllers don’t sit still very well when not being touched, so there numbers jump around a bit. If the value reported from the controller is suppose to be 128 when the stick is in the middle, it might jump around from 130 to 125 in real life. So you would have to write your code to say “If value is between 125 to 130, stop motors” to handle this actuality. This is the controllers dead band.


Hopefully this help. I don’t have time to write the code for you, but I can try to point you in the right direction.