Jitter in running Motors along with Ultrasonic Sensor


I am using blynk to run two motors on NodeMCU and a motor shield connected to a joystick widget. Another arduino sketch reads distance from an ultrasonic sensor and displays on a LCD widget.

However, when I combine both, the wheel has a jitter and if I am running a timer to read ultrasonic sensor every 3 seconds, motors will halt() every three seconds and start.

Anyone has a solution? The code is too lengthy to post and if there is no hope without code, I will rework on it to create a simpler one.

Best Regards,

Just searching for the word jitter will bring up related issues… there is NO hard and fast solution… it is caused but many things (Blynk Libraries, BlynkTimer, millis(), etc) all in the background trying to use the same internal clock timers.

Simply put, you need to make your code very tight, precise, and with lots of timer enables, disables, etc. to share resources. More on the advanced programming side and not really the scope of this forum.

Since I am beginning with Blynk and Coding, this should be difficult. Does anyone have a link to a project which uses nodemcu, blynk, motor shield and ultrasonic sensor together? If that is there, I will try understanding the code.

The only real tricky part is the ultrasonic sensor, due its timing requirements… and if you search this forum for the keywords, like suggested, you should find some example code I have used successfully, by keeping the delays very short, only running the scan when required instead of all the time, and if using servos, enabling and disabling them as required.

Thank you for your response. Can you kindly share any of those links or programs which might help? All the answers are related mostly for servos and in my case, the servo is working perfectly. No hope for ultrasonic sensor yet. I have already spent two days just creating trial and error, but still no hope. Also happy to see that all the topis for searching the term jitter is answered by you.

I don’t know off the top of head… but search for ping and ultrasonic… for the sensor, and robot, car, rover, etc. for use of DC motor control… not sure about any combos of the two.