analogRead from potmeter doesn't work correctly?


i busy playing new motorshield adafruit, i've modified code control dc motor bit can control speed of motor 10k potentiometer, here code;

code: [select]

#include <afmotor.h>

af_dcmotor motor(1, motor12_64khz);
int potpin = 0;
int var0 = 0;
void setup() {
}

void loop() {
 var0 = analogread(potpin);
 motor.setspeed(var0);
 motor.run(forward);
}


but,
(there's but, no exceptions)


when turn pot clockwise motor off, when turn pot ~25% it's @ maximum speed , when turn @ ~26% it's off , @ ~50% it's @ maximum speed , when @ ~51% off, continue's till 100%.

if use 10 ohm pot motor stops when turn pot clockwise , when turn max, nothing happens, takes 15 seconds before starts @ maximum speed (like it's hanging or something).

can me problem?


the analog input 10-bit value ranging 0 1023.  the range var0 apparently smaller.  from description, 25%, etc, seem take byte input (0 255 range).  so after "var0 = analogread(potpin);" add "var0 = var0 / 4;"  this reduce var0 range 0 255.


Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > analogRead from potmeter doesn't work correctly?


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums