Pages: [1]   Go Down
Author Topic: 12VSTEPPER MOTOR CONTROL WITH ANALOG--NEED HELP  (Read 1462 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello I am trying to control a stepper motor with a potentiometer, but eventually I would like to use a pulse sensor to move the motor.

I'm using this biploar stepper motor: http://www.adafruit.com/products/324

I've gotten it to work using this motor sheild:
http://arduino.cc/it/Main/ArduinoMotorShieldR3

using code i found here: http://arduino.cc/forum/index.php?topic=89468.0

But I'm confused as to how to create code that will allow the potentiometer to control this motor.

(I'm new to arduino!!)

Any help would be awesome!! smiley-eek smiley-eek smiley-eek
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49365
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is ironic. Someone named lownoise screaming at us.

Quote
But I'm confused as to how to create code that will allow the potentiometer to control this motor.
So, you've noticed that a stepper motor steps. It does nothing else. How, exactly, do you want a potentiometer to "control" the stepper motor?
Logged

Loudoun County VA
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

By control he means regulate the motor's speed and direction using the potentiometer.

I have the same question, some sample code would be greatly appreciated!

Thanks,
-Slam
Logged

Baltic states
Offline Offline
Jr. Member
**
Karma: 0
Posts: 97
new day, new try
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Let's say you take 10K potentiometer. When you connect it(potentiometer) to arduino, it will show you the numbers from 0 to 1023.
Middle position of potentiometer should show you something about 510-512.
So(if i am not wrong) the code should look like:
val = analogRead(potentiometer_pin);
if(val >= 510K && val <= 512)
stepper.stop();
else if(val >= 513)
turn.right();
else
turn.left();
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49365
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So(if i am not wrong) the code should look like:
val = analogRead(potentiometer_pin);
if(val >= 510K && val <= 512)
Well, that K looks out of place...
Logged

Pages: [1]   Go Up
Jump to: