0

I tried to test a servo motor for a project using this simple circuit but the motor won't move. I've used this before with the same setup and code and it worked, but now suddenly nothing works, even tried a different servo motor. I have tried changing arduinos, changing signal pins , changing servos but nothing works. I had got them to work only a few days back but now suddenly i cant and i dont know where im going wrong. here is my circuit :- image of circuit

#include <Servo.h>
Servo myservo;
int pos = 0; 
void setup()
{
myservo.attach(9);
}
void loop()
{
for (pos = 0; pos <= 180; pos += 1)
{
myservo.write(pos);
 delay(15);
}
for (pos = 180; pos >= 0; pos -= 1)
{
 myservo.write(pos);
delay(15); 
}
}
  • you are like the guy that thinks of replacing an engine in an automobile before he thinks to check if there is any gas in the tank ...... have you checked the voltages on the power supply? – jsotola May 14 at 20:53
0

There's nothing wrong with your code. Check your wiring:

  • Servo brown -> Gnd
  • Servo red -> +5v (not +3v)
  • Servo Orange -> pin 9
  • Connections at the servo-connector and at the Arduino are electrically sound
  • Try swapping the 3 jumper wires (the only parts you didn't say you'd swapped)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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