Why is my "mood cue" not working? I am new to Arduino, and I am working through the "Arduino Projects book," with the Arduino Uno. I am working on project 5, "the mood cue." It is basically a potentiometer-controlled servo. I am certain that I have the code for it correct, and certain that I have all the wiring correct. I have the potentiometer value and the angle at which the potentiometer is turned printed on the serial monitor.

I upload the code, and the serial monitor begins printing correctly, changing when I twist the potentiometer. But the servo doesn't move. It lets off a faint buzzing sound, and that is it.

Does anyone know what the problem is? I don't know what I have done wrong. Do you think my servo is broken?

Here is my code:

#include &lt;Servo.h&gt;
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);
  myServo.write (angle);
  delay(15);
}


Here is my wiring:
file:///C:/Users/matth_000/Downloads/Arduino%20PotServ.jpg
The classic way of wiring up motors, including servos, is to provide them with separate power. The image below should clarify this:



The batteries (in this case) have the sole function of providing power to the servo motor. The "data" pin however goes to the Arduino.

The Arduino itself is powered by the USB cable in this example.

The important point is the blue wire - the shared ground wire. Both the Arduino and the servo (and batteries) must have a common ground.