servo motor keeps twitching

so i am doing this project from the arduino starter kit called mood cue but when i turn on the motor keeps twitching even without programming it

pS: idk if this effect my motor connectors { from top to bottom} is black/white/red while in the book it says
black/red/white

so i tweaked the project abit

so the the black is connected to gnd and red connected to positive while the middle is connected to ~9
and the capacitor is connected positive 2 positive and negative to negative

example of a successful project(not mine)

Could be how you are powering the servo (don't power it from the arduino), your code, or your wiring.

The normal arrangement of servo cables is to have power (v+) on the centre wire so that no harm is done by connecting it the wrong way. One of the other wires is GND and the other is SIGNAL.

You only need to connect SIGNAL to the appropriate Arduino pin and GND to the Arduino GND. If it does not work it only takes a moment to test those two the other way round.

Post your code.
Draw a diagram of how things are connected and post a photo of the drawing.

...R

Robin2:
The normal arrangement of servo cables is to have power (v+) on the centre wire so that no harm is done by connecting it the wrong way. One of the other wires is GND and the other is SIGNAL.

You only need to connect SIGNAL to the appropriate Arduino pin and GND to the Arduino GND. If it does not work it only takes a moment to test those two the other way round.

Post your code.
Draw a diagram of how things are connected and post a photo of the drawing.

...R

here is a an example of the scheme but as u can see the difference is in the motor connectors mine have signal in the middle

CODE:

#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);

myServo.write(angle);
delay(15);
}

here is a an example of the scheme but as u can see the difference is in the motor connectors mine have signal in the middle

In most servos the center wire of the three is red and is the +6v wire, and the two outside wires are the signal and ground wires. Your diagram appears to show you attempting to power the servo from the arduino, which usually causes issues.

That link is not working for me, my internet connection is slow and it just seems to be loading ads.

If it is just a picture please add it as an attachment.

...R

Robin2:
That link is not working for me, my internet connection is slow and it just seems to be loading ads.

If it is just a picture please add it as an attachment.

...R

Done

The image you have added to your Original Post does not seem to me to show what you said in Reply #3

here is a an example of the scheme but as u can see the difference is in the motor connectors mine have signal in the middle

In the image the centre wire is red and seems to be connected to the 5V coming from the Arduino.

The problem is most likely that the Arduino cannot supply enough power for the servo. Give the servo its own power supply with the GND connected to the Arduino GND.

And for the future - don't add data to an old Post - add it where it makes sense in the flow of the discussion - your image should have been in Reply #6

...R