200ohms potenciometer as analog input, Arduino UNO

retrolefty:

fungus:

fofro:
potencmt=a.analogRead(0);

What's the value returned by analogRead(0)?

0.49 is after you've done some math on it. What's the raw, unmodified value?

Which is another way of saying "post your sketch" please.

As a better electrical test, just use your multimeter to measure the wiper terminal voltage while it's wired up to the arduino and check the readings at the two ends of travel and while centered, and confirm that the meter reads 0, +5vdc, and +2.5vdc respectively.

Lefty

The returned value is about 100bytes(I don't recall the precise value) and to transform it into voltage, I just have to multiple it
for 5 and divide it for 1023 due to the pin's resolution of 10bits. The expected value would be 512bytes, which is not happening...

I measured the two ends and the wiper terminal and I got the expected values of 0, 5 and 2.5V respectively.

This is the script I have been using to drive a DC motor with an Arduino Motor shield:

function shield

a=arduino('COM3');

a.pinMode(12,'output'); %DIR A
a.pinMode(13,'output'); %DIR B
a.pinMode(9,'output'); %BRAKE A
a.pinMode(8,'output'); %BRAKE B
a.pinMode(3,'output'); %PWM A
a.pinMode(11,'output'); %PWM B
a.pinMode(14,'input'); % ??

b=0;

while(b==0)

a.digitalWrite(12,1); %
a.digitalWrite(9,0);
a.analogWrite(3, 255);

pause(5);

potmcmt=a.analogRead(0)/1024*5

a.digitalWrite(9,1);
pause(5);

a.digitalWrite(12,0);
a.digitalWrite(9,0);
a.analogWrite(3, 255);

pause(5);
a.digitalWrite(9,1);

end

end

But the values returned by a.analogRead(0) don't correspond to the ones read by the multimeter...