Quantcast
Channel: Sensors - Arduino Forum
Viewing all articles
Browse latest Browse all 1074

Potentiometer not working

$
0
0

My potentiometer seems to be faulty or im doing sometthing very wrong

int const potPin = A0;
int potVal;
int angle;

void setup() {
  // put your setup code here, to run once:
  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);

  delay(15);
}

Im not sure if its a problem in the code or my circuit:

Output without touching it:
potVal: 1023, angle: 179
potVal: 143, angle: 25
potVal: 190, angle: 33
potVal: 709, angle: 124
potVal: 660, angle: 115
potVal: 231, angle: 40
potVal: 328, angle: 57
potVal: 722, angle: 126
potVal: 480, angle: 83
potVal: 207, angle: 36
potVal: 397, angle: 69
potVal: 738, angle: 129
potVal: 384, angle: 67
potVal: 188, angle: 32
potVal: 489, angle: 85

14 posts - 11 participants

Read full topic


Viewing all articles
Browse latest Browse all 1074

Trending Articles