Fluctuatuing Potentiometer on Mood-Cue Starter Project

Hello Hello,

This is my first post here, having trouble with project #5 of the starter kit.
Everything seems to work fine, the servo reacts to the potentiometer reading,
when the potentiometer gets to the maximum value of 1023 I get small fluctautions in it’s signal,
around 1017-1023, which make the servo vibrate constantly.
If I constrain the variable between 0,1000 the fluctuations stop.

Below is the code, incase needed, I also attach a photo of the wiring.


#include <Servo.h>
Servo myServo;

int const potPin = A0;
int potValue;
int angle;

void setup () {

void loop () {

potValue = analogRead(potPin);

Serial.print("Potentiometer Value: ");
// potValue = constrain(potValue,0,1000);
angle= map(potValue, 0, 1023, 0, 179);

Serial.print("\t \t Motor Angle: ");


The problem may not be with a pot, rather with servo. Some doesn't go all way round 0-180, try to remap same input 0-1023 to 10-170 and see what happens. BTW, always use # feature from the bar above re-play/post window, to wrap your code in nice looking inserting.

Thanks!!! It works great now!

Thank you very much, Magician. I was about to ask the same question on the forum, when I found this answer. Indeed it was an issue with the servo. The thing which made me think different at first, was that analogRead() returned the fluctuations. But then I measured the voltage with multimeter and it read no fluctuations. So, remapping for servo values worked!

There is no single solution, a lot would depends on hardware /electrical setup - wiring, type of pot and servo, power supply etc. I just had similar issue with my own servo, it isn’t going all the way up to 180.
Same time implementing low pass filtering in the software wouldn’t hart ether, especially when arduino powered via USB or battery. Arduino IDE has nice example:
File/ Example/ Analog/ Smoothing