Help with microbit and servo acting strangely

Hi there,

Long time lurker, first time poster.

I was demonstrating how to hook up a servo motor to a micro:bit in class today and used the A and B buttons to turn it to 0 and 180 respectively.

While button A worked 100% of the time at the set speed, Button B glitches out and goes both incrementally slowly towards 180 but also stutters back and forth for more than 20 seconds and doesn’t make it to the designated degree. :man_shrugging:t2:

The motor I’m using is from a Sparkfun kit and is a Micro Servo 9g A0090.

I’d appreciate any help I can get!

2 Likes

Hi,

No worries, have you tried switching the direction each button is associated to in your code to ensure that your motor turns correctly in both directions? Also, if you can link through your code here so that we can take a look at it that would be excellent!

3 Likes

Hi @Bryce

Thanks for the reply. I originally had it switched around with A setting the direction to 0º and B to 180º. It did a similar thing, but just the opposite way around. So I don’t believe there’s anything wrong with the motor as it’s been able to swing the arm both ways. The code below is what I’ve got.

1 Like

Hey,

I’ve had a look at your code, and it looks ok! Could you post a picture of your wiring? Perhaps it’s as simple as a continuity error :thinking:

Keen to get to the bottom if this.
-James

1 Like


Hi James,

Sorry for the delayed response! Attached is a picture of my wiring. I’d love to know what I’m doing ‘wrong’ or what is going wrong with it.

Hi guys,
I may be completely off the mark here but I have struggled in the past with Servo’s acting strange due to not receiving enough voltage. If you have a battery pack that has 3 or 4 x AA or AAA batteries that may help as I found just two was not enough to power it up sufficiently.
A little bit more of an involved solution is there is a 5V test point on the back of the Microbit. We ‘delicately’ soldered a wire to this point, and used it instead of the 3V ring on the Microbit and it works really well. Let me know if you want more info on the second option.
Thanks,
Shaun

2 Likes

Hi Shaun,

Thank you so much for that. You may be on to something with your insight into 2x 1.5v AAs not being able to supply enough voltage. I plugged it into my computer and it worked perfectly. I then disconnected it and used the battery pack again, but this time used fresh batteries and it also worked 100% of the time.

I’d definitely be interested in seeing your hack for the 5V test point instead of the 3V ring!

2 Likes

Not a worry. I struggled to get them to work with fresh batteries, and even plugging into the computer so you are doing well there.
I went to this link.

And you can see a little way down the page a yellow wire soldered to the 5V test point. It only works when plugged in via USB though.
Hope this helps!
Shaun

3 Likes