Arduino Starter Kit Servo Problem

I have encountered a problem with running the potentiometer-controlled servo.

The circuit connections were checked physically (visual inspection x 3) and electrically – with continuity tester for connections to power-supply terminals and the Arduino pins

The output from the potentiometer wiper was checked with a 4 ½ digit autoranging multimeter to check that it was 1) connected properly to +5V supply, 2) outputting a variable voltage. The pot wiper is outputting a variable voltage from 0V dc to 4,77V dc depending on wiper position, which seems correct.

No other connections are relevant and all connectivity has been checked.

Uploading the program compiles without notified errors and uploads (apparently) correctly –

Observations: 1) upon upload, the servo shocks three times and positions itself at roughly 85 degrees; when settled there, it remains constant and no potentiometer input makes any difference to it although the voltage can be seen to vary from the pot wiper.

The previous simple experiment (servo sweep) operates correctly therefore the servo is operational.

Recompiling and re-uploading the program does not solve the problem.

It would appear to me therefore, that with all components intact and interconnectivity intact and properly connected, there is something amiss with the program itself.

Please advise??

Post code.

AWOL: Post code.

.... and pic :roll_eyes:

With all due respect to replying readers - it appears to me that you have ^not^ read my initial analysis correctly - please ensure that you have done so?

The code used is identical in two instances: 1) the one supplied in the Arduino Starter Kit; 2) the one supplied in the Arduino Kit page online as "KNOB" - in both cases the circuit is also identical.

Please re-read my observations - these effectively answer all questions you have posed so far.

Any help here would be appreciated, Kind Regards, FV

Neither of us posed a question, nor can we see the code or the circuit from where we are.

No, we read your initial analysis, which is why we're asking to see exactly what you can see.

It may surprise you, but some of us have never seen a starter kit, its contents or any of the sketches.

It isn't unusual for noobs to miss out something important, or change a line of code inadvertently.

Try this:

const byte potPin = A0;  //your analogue input pin here
void setup ()
  Serial.begin (9600);
void loop ()
  Serial.println (analogRead (potPin));

Here is the code - supplied identically in two official instances:

// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin

void setup()
myservo.attach(9); // attaches the servo on pin 9 to the servo object

void loop()
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there

I do not see how to supply copy of circuit as JPG or PNG here but address for ref which shows it is:

Thanks for all help,

FV, your problem is your circuit. I just checked the sketch and it works fine!

For what it's worth, I found that remaking the circuit again a little later using comletely different positions on the board tended to solve things like this. In fact, the only problems I had completing the starter kit were physical, ie either me wiring things in the wrong way or because of badly fitting components. Good luck!

I had problems with this circuit aswell try googling the servo motor you have and take note of the pinouts the servo motor I have is wired in the plug different to the circuit. It looks like the pins have been put in the wrong holes on the plug reconfigured and all ok.


I cut and paste the code you posted, hooked up an HXT900 servo ala the “knob” circuit and it worked as advertised. There is nothing wrong with the code which must have been used a zillion times by now. I use a modified version of that very sketch to run two servos with a 2-pot joystick: no problems.

I don’t know what servo comes with the kit though: it might be that it needs more current than the Arduino is happy to supply. Maybe try hook it up with its own power supply, ala attached pic? Edit… quite a lot of servo “funnies” like disobedience and the shakes can be corrected by a better power supply: so it’s a common thing to sort out soon as you experience a problem. If nothing else, it eliminates one possible source of the problem, and who knows, often it fixes it… (Although it’s strange in your case that “sweep” works which would tend to exonerate the power supply and the servo and the connections.)


PS… to attach pix to posts, click the Additional Options link just below the typing area.

Edit PPS… maybe post a photo of your actual setup?

What program do you use to make these diagrams?



Thanks downloaded