Unipolar Stepper Motor & MotorShield & Potentiometer
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Unipolar Stepper Motor & MotorShield & Potentiometer

by boneva on Wed Dec 19, 2012 3:53 pm

Hello guys,

I am a quite beginner in electronics and programming.. I bought the adafruit motor shield and connected successfully an unipolar stepper motor with 5 wires. Now I want to control the motor with a potentiometer (attached it on Analog Pin = 1) and read as well how many steps the motor is driving. I did'n find any tutorial about how to use the AFmotor Library to set the analog input to write on my M3 an M4 pins.. How do I navigate the library in a way to control the motor direction and velocity (steps number) so I can drive it from my potentiometer? I am working on kind of objects which should rotate with different amount of steps depending on the potentiometer input.

p.s.
i did find a similar code, but here they don't use the motor shield..

[Edit - moderator - use the 'code' button when submitting code]
Code: Select all | TOGGLE FULL SIZE
// program a unipolar stepper motor to be controlled by a potentiometer
// a stepper motor is the best choice for controlling motor speed with the greatest accuracy
// its accuracy is based on the number of ticks per rotation, like a watch motor
 
int motorPin1 = 2;
int motorPin2 = 3;
int motorPin3 = 4;
int motorPin4 = 5;
int analogPin = 1;
int delayTime = 50;
int val;   // reads the input pin; val is a number coming in thats btwn 0 and 1023
void setup() {
  Serial.begin(9600);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
}
void loop() {
  int val = analogRead(analogPin);   // read the input pin; val is a number coming in thats btwn 0 and 1023
  Serial.println(val); // makes sure that potentiometer is working
  delayTime = (val /3) + 15 ; // factors in time before the motor makes another step in speed
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, HIGH);
  delay(delayTime);
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delayTime);
}

I would be very happy if you could help me on this one..

thanks and best regards,
valentina
Attachments
photo.JPG
photo.JPG (451.13 KiB) Viewed 1545 times
boneva
 
Posts: 4
Joined: Wed Dec 19, 2012 10:15 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

by adafruit_support_bill on Wed Dec 19, 2012 3:58 pm

Hi,
Where did you purchase the motor shield? It looks like an older model than the one we are currently shipping.

adafruit_support_bill
 
Posts: 39322
Joined: Sat Feb 07, 2009 10:11 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

by boneva on Thu Dec 20, 2012 5:46 am

On the website I guess, my school has a bunch of hardware that they order every year and I bought it from there.
Does that make some difference in the library?

greetings
boneva
 
Posts: 4
Joined: Wed Dec 19, 2012 10:15 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

by adafruit_support_bill on Thu Dec 20, 2012 6:05 am

Does that make some difference in the library?

Not sure. Can you post the link to your source so we can be sure of exactly what you have there?

adafruit_support_bill
 
Posts: 39322
Joined: Sat Feb 07, 2009 10:11 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

by boneva on Thu Dec 20, 2012 7:34 am

My source? Do you mean the exact model of the shield?
I didn't recognized the difference in the model so I just downloaded the library from the website and installed it, everything with the test script worked out.
boneva
 
Posts: 4
Joined: Wed Dec 19, 2012 10:15 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

by adafruit on Thu Dec 20, 2012 7:52 am

boneva wrote:My source? Do you mean the exact model of the shield?
I didn't recognized the difference in the model so I just downloaded the library from the website and installed it, everything with the test script worked out.


hiya! where did you purchase this from?

adafruit
 
Posts: 11949
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

by boneva on Thu Dec 20, 2012 11:15 am

I bought it from http://www.watterott.com/de, but they don'have it on the website, they order it from you on adafruit.com.
the model is motorshield 1.0
boneva
 
Posts: 4
Joined: Wed Dec 19, 2012 10:15 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

by adafruit on Thu Dec 20, 2012 5:37 pm

boneva wrote:I bought it from http://www.watterott.com/de, but they don'have it on the website, they order it from you on adafruit.com.
the model is motorshield 1.0


can you email us support@adafruit.com with your watterott order # ?

thanks!

adafruit
 
Posts: 11949
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Please be positive and constructive with your questions and comments.


cron