Microsoft MakeCode

Servo Question

Please help - I’m a teacher and class is trying to make a robot with a head that turns. The TowerPro servo is supposed to move from 30 to 150 degrees. Instead it is moving unreliably and often crazily backwards and forth after reaching near to its angle. Image of code and video of problem - Links below
I am using a battery pack of 4AAA to power that servo. Is it a power problem? I have replaced all batteries and done a lot of testing with code and servos, and still cant find a solution.

I can’t quite tell from the video: Is the Micro:bit ground (GND) connected to the battery and servo ground? (It looks like it may be, but it’s hard to tell if the wire is really connected)

I found out that the shuddering is caused by electrical noise. Using cheaper knockoffs of the TowerPro SG90 avoids the problem!
I got this advice : ‘When using a digital servo, you need to have isolation between the controller and the motor driver. You should have isolation when driving any motor but the low power analogue (cheaper) motors don’t jitter, but also don’t hit the same spot.’
I hope this helps others.
Thanks very much for taking a look.