Hello, first post as I am VERY new to this whole field. I am trying to control the speed of a stepper motor (two eventually) using a 10K potentiometer. I have the following components:
- Arduino R3
- Adafruit V1 Motor Shield L293D
- Two Vexta Model C5919-9012 Bi-Polar stepper motors with 200 steps and 0.14A
I am powering the motors with an external 12VDC power source. I have also tried a 5V power source through the Arduino as well. The code I found passes the checks but there is no response from the motor.
Here is the wiring setup:
#include <AFMotor.h>
AF_Stepper stepper1(100, 1);
int analogPin = A0; // Pin analog
int val = 10; // variable to store the value read
int prepos = 0;
int pos = 0; //0 to 224
void setup()
{
stepper1.setSpeed(10);
Serial.begin(9600);
}
void loop()
{
prepos = pos;
val = analogRead(analogPin); // read the input pin
//pos = map (analogRead(analogPin), 0, 1023, 0, 200);
// read pot and map to stepper speed
int spd = map (analogRead(analogPin), 0, 1023, 0, 200);
stepper1.setSpeed(spd);
if (pos != prepos)
{
int diststep = pos;
if (diststep > 0)
{
stepper1.step(diststep, FORWARD, DOUBLE);
}
}
}
Any help is greatly appreciated.
6 posts - 4 participants