I have been working on a self balancing with the MPU6050 using DMP to get pitch values which I use it with a PID controller. The code seems to be working fine as shown in the video. But as soon as I put the bot on the ground to do its thingy MPU starts giving erratic values and the bot goes ham mostly causing arduino to freeze or the motor jitters.
I have gone through numerous articles and forums trying to debug.
I am powering the arduino uno from the USB and the motor controller(L298N) is powered by a 3S Lipo.
To eliminate the issue caused by motor noise I have added 3 0.1uf caps to both the motors. I am pretty inclined that its a hardware issue and not an issue on the code side. Would like to hear what do you guys think, pretty much stuck on this for couple of days now. Thanks for the help!
link to the video: https://youtu.be/diJG3d6wrv0
I have also attached the complete code if anyone wants to go through that
SSBCode.txt (7.48 KB)