Mood Cue is jumpy

So this should be a simple project out of the Arduino Project Book-Starter Kit but instead. What is supposed to allow me to turn the potentiometer to indicated my mood has turned into an Arduino monster that has had too much caffeine and just sites there and twitches. Does not seem to even respond to the turning of the potentiometer.

I have included copy of my code and a picture of my board.

Thanks for the help.

Out put of values generated by the twitch.
potVal: 295, angle: 51
potVal: 295, angle: 51
potVal: 278, angle: 48
potVal: 273, angle: 47
potVal: 261, angle: 45
potVal: 224, angle: 39
potVal: 215, angle: 37
potVal: 197, angle: 34
potVal: 275, angle: 48
potVal: 236, angle: 41
potVal: 238, angle: 41

#include <Servo.h>
Servo myServo;
int const potPin = A0;
int potVal;
int angle;
void setup(){
  myServo.attach(9);
  Serial.begin(9600);
}

void loop(){
  potVal=analogRead(potPin);
  Serial.print("potVal:  ");
  Serial.print(potVal);
  angle=map(potVal,0,1023,0,179);
  Serial.print(", angle:  ");
  Serial.print(angle);
  Serial.println("");
  myServo.write(angle);
  delay(1000);
}

Your servo should have its own power supply. It should not be pulling its power through the arduino like that. Arduino can't supply enough current, the voltage sags, the board resets, and the servo twitches.

Checked the voltage on the servo and it indicates that it is 5V. If I am following the project instructions correctly, it indicates that by placing a 100uf capacitor between the power and ground it is supposed to smooth out my power demand. Apparently this is called decoupling capacitors. I also have no way of powering a 5V servo as the only other power source is a 9V battery.

dgkindy:
Checked the voltage on the servo and it indicates that it is 5V. If I am following the project instructions correctly, it indicates that by placing a 100uf capacitor between the power and ground it is supposed to smooth out my power demand. Apparently this is called decoupling capacitors. I also have no way of powering a 5V servo as the only other power source is a 9V battery.

Then you need to invest in some AA batteries or a good wall adapter and a voltage regulator. The 9V won't last more than a few minutes driving a servo. And if you try to pull that much current through the Arduino, with a cap across it or not, you're going to cause issues and possibly even damage your Arduino board.

Instead of guessing at whether it's resetting, let's FIND OUT!

Print something to serial in setup - that way you'll know if the board is resetting like we suspect....

So to DrAzzy’s suggestions I added a println in setup and this line only appears one in the serial output

Setup is complete
potVal: 0, angle: 0
potVal: 0, angle: 0
potVal: 0, angle: 0
potVal: 0, angle: 0
potVal: 0, angle: 0
potVal: 0, angle: 0
potVal: 0, angle: 0
potVal: 0, angle: 0
potVal: 0, angle: 0

I have changed out the potentiometer with one that does seem to plug into the breadboard nicer than the other one. I also added in a delay to slow the chatter down but as you may have noticed in the data listed above, it is not jumping around anymore but it also will not move from from 0

#include <Servo.h>
Servo myServo;
int const potPin = A0;
int potVal;
int angle;

void setup(){
  myServo.attach(9);
  Serial.begin(9600);
  Serial.println("Setup is complete");
}

void loop(){
  potVal=analogRead(potPin);
  Serial.print("potVal:  ");
  Serial.print(potVal);
  angle=map(potVal,0,1023,0,179);
  Serial.print(", angle:  ");
  Serial.print(angle);
  Serial.println("");
  myServo.write(angle);
  delay(1000);
}

I have changed out the potentiometer with one that does seem to plug into the breadboard nicer than the other one.

You need to post a schematic. Even something hand-drawn would be good. A picture of the actual implementation of the schematic would not be amiss.

it is not jumping around anymore but it also will not move from from 0

Check the wiring. If you connect A0 directly to 5V or GND what values do you get ?

I had trouble with the servo going back and forth, but it was only a wire on the potentiometer that needed to be pushed further down into the breadboard.

Im having the same problem but none of the solutions are working