hi im doing a project in which i have to move a stepper at a constant speed when button pressed, and the another at a variable speed with a potentiometer both at the same time. please help i dont have time to buy any drivers or shields what can i do?
I guess I would ask the obvious question, what DO you have? Any transistors handy? Maybe a driver chip like a ULN2003? You're certainly going to need something in between the arduino (40ma) and the stepper motor.
yhea i have 2 uln2003´s and 2 unipolar motors
Have you taken a look at:
thats the thing i dont know how to write the code say (3,4,5,6) are my1ststepper outputs to the ULN2003 and (7,8,9,10) are to my2ndstepper. im goint to have a variable volt input from my POT in my analog 0.
my 1st stepper is going to stay on at a constant speed
my 2nd stepper variable speed depending on the input value
how would i write it ?
Just fleshing out the MotorKnob code (not tested):
...
Stepper constantSpeedStepper(STEPS, 3, 4, 5, 6);
Stepper variableSpeedStepper(STEPS, 7, 8, 9, 10);
void setup()
{
constantSpeedStepper.setSpeed(30);
variableSpeedStepper.setSpeed(30);
}
void loop()
{
// get the sensor value
int potInput = analogRead(0);
//Complete guesses, tweak as needed (would probably be better as "defines" btw)
int lowestPotValue = 0;
int highestPotValue = 1024;
int lowestNumberOfSteps = 0;
int highestNumberOfSteps = 10;
int amountOfSteps = map(potInput, lowestPotValue, highestPotValue, lowestNumberOfSteps, highestNumberOfSteps);
variableSpeedStepper.step(amountOfSteps);
int amountOfStepsContantSpeedStepperMovesPerLoop = 1; //Again, a guess
constantSpeedStepper.step(amountOfStepsContantSpeedStepperMovesPerLoop);
}
wont this wait until the variablemotor ends its steps and then go´s to the constant? this will do it simultaneously?
It will wait, but depending on your application, it's usually not perceivable. Technically speaking, there's no straight forward way to have them both being stepped at the same time, that is w/o additional hardware, or some pretty hilarious bit banging. As a hardware solution, something like a decade counter or shift register setup would work, but again, typically, alternating between the two is sufficient.
Oh, and FWIW, I've heard good things about the Adafruit stepper library, although I haven't used it. They claim it's simultaneous, but in actuality, it's toggling between the two as described earlier. The library is here:
Eddman132:
i dont have time to buy any drivers or shields
Eddman132:
i dont know how to write the code
It's not clear what level of expertise you have, but the comments above imply that you aren't a strong coder, don't have the option of obtaining the hardware that would make this easy for you, and so you're taking the harder approach of making your own driver circuit. This will also require you to write the software to interface to it. Is it realistic for you to build the hardware and write the software in the time available?