4

I have a simple MG996 servo motor and I am trying to make it move with my Arduino Uno. I tried different ways of wiring but nothing seems to work as fully expected.

For the wiring I followed this video: https://www.youtube.com/watch?v=b_xvu6wWafA and at 9:02 min the guy is showing how the wiring is done. As you can see in my photo, I have done the same thing (as you can see in the "my wiring" picture), with an external battery pack and everything but my code still does not work. No errors or anything, compiles and uploads perfectly. The code I was trying to execute is:

#include <Servo.h>

Servo myservo;

void setup() {
  myservo.attach(8);
}

void loop() {
  myservo.write(0);
  delay(1000);
  myservo.write(90);
  delay(1000);
}

This code is essentially trying to move the servo from 0 to 90 degrees back and forth. The pin is the correct one (#8). The arduino is receiving the right code (because I tried it with exemplary ones).

Important note: One thing I tried, however, was to not even have an external battery pack. Just connect the wires like so but instead of the 2 GNDs, only 1 GND and 1 +5V pin. That way I was able to move the servo only forward but never backwards! And every time I wanted to move it I had to write a higher degree value.

So the question is, is my wiring bad? I must be missing something.

Photos: My wiring

2
  • 1
    It looks like you have it wired to Vin? That's a voltage in pin. You probably want 5V.. It's pretty hard to tell anything from the pic, though; diagrams are easier to understand. Commented Aug 14, 2021 at 8:59
  • You can cross check your circuit diagram and code with this tutorial. This one uses MG996: theengineeringprojects.com/2017/05/…
    – tepalia
    Commented May 2 at 16:11

1 Answer 1

5

You have not connected the supply pin properly. here is the connection diagram for the standard basic Arduino example I also verified this on the video you have linked. Connect the 5V and you should be good to go.

https://wokwi.com/arduino/projects/306894988845777472

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.