user56673: 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); 
}
}


user313: 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)


56673: <p>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.
<strong>here is my circuit</strong> :- <a href="https://drive.google.com/file/d/1bN1CF5VlAhcG8v71h5JyR1pCtpMfZNL6/view?usp=drivesdk" rel="nofollow noreferrer">image of circuit</a></p>

<pre><code>#include &lt;Servo.h&gt;
Servo myservo;
int pos = 0; 
void setup()
{
myservo.attach(9);
}
void loop()
{
for (pos = 0; pos &lt;= 180; pos += 1)
{
myservo.write(pos);
 delay(15);
}
for (pos = 180; pos &gt;= 0; pos -= 1)
{
 myservo.write(pos);
delay(15); 
}
}
</code></pre>
 313: <p>There's nothing wrong with your code. Check your wiring:</p>

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