Go Down

Topic: Project 05 Mood Cue: Servo and Pot not working as expected (Read 812 times) previous topic - next topic

archivalboat50

Hey guys, the issue here is that my servo only seems to turn by itself very little, and is not affected by the potentiometer at all. I can't seem to find what I'm doing wrong.

Here is my code:
Code: [Select]
#include <Servo.h>
Servo myServo;
int const potPin = A0;
int potVal;
int angle;

void setup() {
  myServo.attach(9);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  potVal = analogRead(potPin);
  Serial.print("potVal: ");
  Serial.print(potVal);
  angle =  map(potVal, 0, 1023, 0, 179);
  Serial.print(", angle: ");
  Serial.println(angle);
  myServo.write(angle);
  delay(15);
}


Here is what the readings look like:
angle: 62
potVal: 360, angle: 62
potVal: 376, angle: 65
potVal: 360, angle: 62
potVal: 360, angle: 62
potVal: 359, angle: 62
potVal: 359, angle: 62
potVal: 359, angle: 62
potVal: 359, angle: 62
potVal: 358, angle: 62
potVal: 358, angle: 62
potVal: 358, angle: 62
potVal: 358, angle: 62
potVal: 358, angle: 62
potVal: 357, angle: 62
potVal: 357, angle: 62
potVal: 357, angle: 62
potVal: 356, angle: 62
potVal: 356, angle: 62
potVal: 356, angle: 62
potVal: 356, angle: 62
potVal: 356, angle: 62
potVal: 356, angle: 62
potVal: 356, angle: 62
potVal: 355, angle: 62
potVal: 355, angle: 62
potVal: 355, angle: 62
potVal: 355, angle: 62
potVal: 355, angle: 62
potVal: 355, angle: 62
potVal: 354, angle: 61
potVal: 353, angle: 61
potVal: 354, angle: 61
potVal: 354, angle: 61
potVal: 354, angle: 61
potVal: 353, angle: 61
potVal: 353, angle: 61
potVal: 353, angle: 61
potVal: 353, angle: 61
potVal: 352, angle: 61
potVal: 352, angle: 61
potVal: 352, angle: 61
potVal: 352, angle: 61

It just seems to barely turn and isn't affected by the potentiometer at all

Here is a picture of my circuit:

Circuit Image

Thanks for the help

 

rogertee

Remove the capacitor on the pot ? Is it a 10k pot

archivalboat50

I have no idea. All the videos I have watched for this project showed a white pot. I think the reason this may not be working is that I'm using the wrong pot. Would that be the case?

ballscrewbob

The colour of the pot does not matter but the value of the pot and they type DOES.

There are two types of pot LINEAR and TAPER. These give different responses over the turning range of the pot.

There are multiple sizes and it is usually either written on or coded on in some form eg 1K 5K 10K or 101, 104 or some other form of number that you can look up on google quite easily.

There are also some other variations such as wirewound and multiturn but for the most part you would concern yourself with the actual value.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Go Up