so project trying hook 2 different stepper motors 2 different potentiometers. using various videos , webpages have set thought work correctly. problem running if both of potentiometers controlling both of motors instead of 1 controlling 1 , other controlling other.
here code using.
my understanding of code 1 controls 1 , other controls other. don't see problem in code has there because know setup correct.
any thoughts or suggestions?
here code using.
code: [select]
int sensorpin2 = a5; //puller motor
int sensorvalue2 =0;
int sensorpin1 = a4; //gearbox motor
int sensorvalue1 =0;
void setup() {
pinmode(8, output); //direction pin2
pinmode(9, output); //step pin2
digitalwrite(8, low);
digitalwrite(9, low);
pinmode(2, output); //direction pin1
pinmode(3, output); //step pin1
digitalwrite(2, low);
digitalwrite(3, low);
}
void loop() {
sensorvalue2 = analogread(sensorpin2);
sensorvalue2 = map(sensorvalue2,0,1023,0,1500);
digitalwrite(9, high);
delaymicroseconds(sensorvalue2);
digitalwrite(9, low);
delaymicroseconds(sensorvalue2);
sensorvalue1 = analogread(sensorpin1);
sensorvalue1 = map(sensorvalue1,0,1023,0,1000);
digitalwrite(3, high);
delaymicroseconds(sensorvalue1);
digitalwrite(3, low);
delaymicroseconds(sensorvalue1);
}
my understanding of code 1 controls 1 , other controls other. don't see problem in code has there because know setup correct.
any thoughts or suggestions?
the problem use of "delay" functions. don't. study blink without delay example in arduino ide see how avoid them. there helpful post: http://forum.arduino.cc/index.php?topic=223286.0
Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Problem controlling two stepper motors with two potentiometers
arduino
Comments
Post a Comment