Unipolar Stepper Motor & MotorShield & Potentiometer

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Unipolar Stepper Motor & MotorShield & Potentiometer

Postby boneva » Wed Dec 19, 2012 2: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
// 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 1065 times
boneva
 
Posts: 4
Joined: Wed Dec 19, 2012 9:15 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

Postby adafruit_support_bill » Wed Dec 19, 2012 2:58 pm

Hi,
Where did you purchase the motor shield? It looks like an older model than the one we are currently shipping.
User avatar
adafruit_support_bill
 
Posts: 16078
Joined: Sat Feb 07, 2009 9:11 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

Postby boneva » Thu Dec 20, 2012 4: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 9:15 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

Postby adafruit_support_bill » Thu Dec 20, 2012 5: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?
User avatar
adafruit_support_bill
 
Posts: 16078
Joined: Sat Feb 07, 2009 9:11 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

Postby boneva » Thu Dec 20, 2012 6: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 9:15 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

Postby adafruit » Thu Dec 20, 2012 6: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?
User avatar
adafruit
 
Posts: 10491
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

Postby boneva » Thu Dec 20, 2012 10: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 9:15 am

Re: Unipolar Stepper Motor & MotorShield & Potentiometer

Postby adafruit » Thu Dec 20, 2012 4: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!
User avatar
adafruit
 
Posts: 10491
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc


Return to Arduino Shields from Adafruit

Who is online

Users browsing this forum: mibignistinly and 2 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [108]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
Android[6]
 
BeagleBone[24]
 
XBee[10]
More Dev Boards[31]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[34]
LCDs & Displays[48]
Components & Parts[70]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[111]
 
Wireless[14]
Cables[62]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]