Problems with servo motors and pots (Project 05 Mood Cue).

Hey guys, I'm extremely new to electronic circuits and fairly new to programming. I was using the starter kit and have had no real issues till the most recent project, 05. Essenially it uses a pot to control a servo motor. Here is my code:

const int potMeterPin = A0;
const int ServoOutputPin = 10;

int angle;
int potValue;

#include <Servo.h>

Servo theServo;

void setup (){

Serial.begin(9600);
theServo.attach(ServoOutputPin);

}

void loop ()
{

potValue = analogRead(potMeterPin);

angle = map(potValue, 0, 1023, 0, 179);

Serial.println("The pot value is: ");
Serial.println(potValue);
Serial.print("The angle is: ");
Serial.println(angle);

theServo.write(angle);
delay(500);

}

A few problems come up. The pot is twisted as far as it goes on one end and I'm getting these readings: keep in mind the servo motor is not responding.

The pot value is:
406
The angle is: 71
The pot value is:
386
The angle is: 67
The pot value is:
372
The angle is: 65
The pot value is:
361
The angle is: 63
The pot value is:
354
The angle is: 61
The pot value is:
347
The angle is: 60
The pot value is:
340
The angle is: 59
The pot value is:
335
The angle is: 58
The pot value is:
331
The angle is: 57
The pot value is:
329
The angle is: 57
The pot value is:
329
The angle is: 57
The pot value is:
331
The angle is: 57
The pot value is:
335
The angle is: 58
The pot value is:

It stabilizes at 58 - 60, but it doesn't do anything, even if I twist the pot to a different value. I've tried replacing the pots and the wires but I keep getting the same results. Servo.write also wouldn't work if I did

const int potMeterPin = A0;
const int ServoOutputPin = 10;

int angle;
int potValue;

#include <Servo.h>

Servo theServo;

void setup (){

Serial.begin(9600);
theServo.attach(ServoOutputPin);

}

void loop ()
{

potValue = analogRead(potMeterPin);

angle = map(potValue, 0, 1023, 0, 179);

Serial.println("The pot value is: ");
Serial.println(potValue);
Serial.print("The angle is: ");
Serial.println(angle);

theServo.write(angle);
delay(500);

}

In the end I tried using the prebuilt example in the IDE, but I got the same results. Maybe it's something in the circuit? Here's a picture of the circuit I made(excuse me for the crappy management). Imgur: The magic of the Internet

Thanks for the help.

In the photograph the pot does not appear to be connected to anything and if the 3 pin lead at the far end of the board is the servo connection then that does not appear to be connected to anything either.

On all breadboards I have seen the connections do not cross the center groove. Use one side or the other.

Thanks for the help! I always assumed from the beginning of that book that the metal strips underneath run across, but i guess that's the wrong format. I organized the board a little bit more and to my dismay it didn't work. Here's a top down picture of my board, if you guys wanted a closer look. Imgur: The magic of the Internet

I installed the IDE on my C: SSD Drive, instead of the default hard drive, so maybe a few libraries are missing? I don't know, it's a dilemma.

Try the servo sweep example under Files, Examples, Servo and if it works Pin 9.

Try the servo sweep example under Files, Examples, Servo and if it works Pin 9.

Holy shit thank you so much. I've been able to fix the servo issues thanks to that... turned out I over complicating things and made too many constants. The servo now accurately depicts the crappy pot, trembling around 60 degrees. One less thing to fix, thanks for the help!!!

update: another clue: I decided to ditch the pot idea and replaced it with a phototransister, i expected atleast something different to happen but i weirdly got the same problem, the analog input stuck reading at ~340

Please post details of your circuit as it is now.

Did you use a voltage divider?

GND -- Phototransistor --- Resistor (10k) -- +5v
|
|
Analog pin