# Potentiometer/code error

**URL:** <https://forum.arduino.cc/t/potentiometer-code-error/1466063>\
**Category:** Mega 2560\
**Created:** [November 1, 2026, 9:42am UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063 "2026-11-01T09:42:48Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon789456](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/anon789456/32/1289128_2.png) [@anon789456](https://forum.arduino.cc/u/anon789456)\
**Post date:** [November 1, 2026, 9:42am UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/1 "2026-11-01T09:42:48Z")

</div>

Attempting to make a simple code that gives the Voltage(V) of leg3 on my potentiometer (POT) (just a beginner ). However, when the POT reads near its min (0.1 ohm), my serial monitor reads 522 and at its max (10k), 1023. But, moving the pot from 0% to 85% of its range, returns 522 - 585, then instantly starts climbing to 1023 (586 -1023) for the remainder of its %.  
Nothing is wrong with the breadboard or POT. Even tried using diff gnd pins, and A# pins. I put in the the code I used but I've already recoded it a few times. Does anyone know how to fix this situation or possibly explain what I'm doing wrong, it'd be greatly appreciated!

```arduino
int readPin=A3;
float leg1=0;

void setup() {
Serial.begin(9600);
}

void loop() {
leg1=analogRead(readPin);
Serial.println(leg1);
delay(100);
} 

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [November 1, 2026, 9:50am UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/2 "2026-11-01T09:50:42Z")

</div>

Welcome to the forum

Seeing a schematic of your setup would help

Is it a linear pot or a logarithmic pot ?

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [November 1, 2026, 10:04am UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/3 "2026-11-01T10:04:15Z")

</div>

> [@anon789456](#):
>
> Nothing is wrong with the breadboard or POT

Please explain why you say that. You said you are a beginner (or at least I think that's what you meant to say, because I have never heard of a beginner pot).

Have you tried a different pot? Or a different breadboard? Or at least a different part of the breadboard.

Even though you haven't shared details of your wiring, I can immediately imagine a likely cause. You are using a breadboard with a non-breadboard-compatlble Arduino, a Mega. That forces you use use Dupont cables, and these are notorious for their unreliability. Have you tried testing out at least replacing each one you are using?

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [November 1, 2026, 10:06am UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/4 "2026-11-01T10:06:52Z")

</div>

Does the breadboard have continuous power strips along its edges or do they have gaps in the middle ? If the latter then have you got connections to each side of the break ?

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [November 1, 2026, 12:48pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/5 "2026-11-01T12:48:03Z")

</div>

> [@anon789456](#):
>
> the Voltage(V) of leg3

```arduino
Serial.println(leg1);

```

but your code says leg1

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [November 1, 2026, 1:26pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/6 "2026-11-01T13:26:56Z")

</div>

What kind of pot, linear, log?

---

<div class="post-metadata">

**Author:** ![JCA34F](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jca34f/32/340148_2.png) [@JCA34F](https://forum.arduino.cc/u/JCA34F)\
**Post date:** [November 1, 2026, 2:14pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/7 "2026-11-01T14:14:29Z")

</div>

Sounds like you have a "volume control" pot with a logarithmic taper that more closely matches the non linear response curve of human hearing, a type "A" pot. Look at the back of the pot and post the lettering there (if any).

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [November 1, 2026, 4:11pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/8 "2026-11-01T16:11:53Z")

</div>

What are the characteristics of a linear pot versus log pot, that @anon789456 can observe on the DMM?

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [November 1, 2026, 4:14pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/9 "2026-11-01T16:14:21Z")

</div>

At one end of the track a small movement of the pot wiper will produce a small change in resistance whilst at the other end of the track the same size of movement will produce a much larger change in resistance

---

<div class="post-metadata">

**Author:** ![EmilyJane](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/emilyjane/32/821537_2.png) [@EmilyJane](https://forum.arduino.cc/u/EmilyJane)\
**Post date:** [November 1, 2026, 4:15pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/10 "2026-11-01T16:15:45Z")

</div>

![Screenshot 2026-11-01 at 10.15.14 AM](https://europe1.discourse-cdn.com/arduino/original/4X/0/9/4/094f119393a8a1d96746bdac91fd3fa29e34d82e.png)

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [November 1, 2026, 4:16pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/11 "2026-11-01T16:16:59Z")

</div>

Is this observable with a DMM? (no graphic output)

---

<div class="post-metadata">

**Author:** ![kmin](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kmin/32/1147370_2.png) [@kmin](https://forum.arduino.cc/u/kmin)\
**Post date:** [November 1, 2026, 4:17pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/12 "2026-11-01T16:17:38Z")

</div>

Log or linear, it shouldn't start from 522..

---

<div class="post-metadata">

**Author:** ![EmilyJane](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/emilyjane/32/821537_2.png) [@EmilyJane](https://forum.arduino.cc/u/EmilyJane)\
**Post date:** [November 1, 2026, 4:18pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/13 "2026-11-01T16:18:37Z")

</div>

Not nearly as easily.

---

<div class="post-metadata">

**Author:** ![JohnLincoln](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@JohnLincoln](https://forum.arduino.cc/u/JohnLincoln)\
**Post date:** [November 1, 2026, 4:23pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/14 "2026-11-01T16:23:12Z")

</div>

> [@xfpd](#):
>
> Is this observable with a DMM?

- Set the potentiometer to it's mid position.
- Measure the resistance between the wiper and each end.
- For a linear potentiometer the two values should be similar.
- For a logarithmic potentiometer, one value should be about ten times the other.

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [November 1, 2026, 4:24pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/15 "2026-11-01T16:24:12Z")

</div>

Describing pot-turns-versus output might help @anon789456  
Mark five spots along the pot dial and map them...

```arduino
        1 2 3 4 5 6
Linpot 0 1 2 3 4 full
Logpot 0 1 1 3 5 full

```

---

<div class="post-metadata">

**Author:** ![EmilyJane](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/emilyjane/32/821537_2.png) [@EmilyJane](https://forum.arduino.cc/u/EmilyJane)\
**Post date:** [November 1, 2026, 4:25pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/16 "2026-11-01T16:25:48Z")

</div>

Yeah, I counted that as graphic output, albeit paper and pencil.

---

<div class="post-metadata">

**Author:** ![JohnLincoln](https://avatars.discourse-cdn.com/v4/letter/j/7ba0ec/32.png) [@JohnLincoln](https://forum.arduino.cc/u/JohnLincoln)\
**Post date:** [November 1, 2026, 4:28pm UTC](https://forum.arduino.cc/t/potentiometer-code-error/1466063/17 "2026-11-01T16:28:34Z")

</div>

> [@anon789456](#):
>
> Attempting to make a simple code that gives the Voltage(V) of leg3 on my potentiometer

I don't know how the pins of you potentiometer are numbered, but I would have thought that the wiper would normally be designated as pin2.

The wiper is the one that I would have connected to the Arduino analogue input.
