Hi ,
im very new at arduino word .i just join the forum.i am in dead end as i dont know cc++ and i was searching around to find a way to make my project work.Finaly i decided to ask all of you.
I have 2 stepper motors nema 17 200steps, 2 drivers DRV8825 2 pushbuttons, 2 limit switches and a genuino uno.
i want to move the 2 steppers with the 2 drivers but i couldn't find something ready
i'm confused witch library to use ...
i hope someone has the patience and the willingness to help me!
i want to do two things:
1)when i push button1
i want to move stepper1 clockwise till it reach limitswitch1 and then go counterclockwise 1/4 rev.
and stay there. The same time stepper 2 clockwise till it reach limitswitch2 and stay there .
2)when i push button 2
i want to move stepper1 specific time,speed,dir,and also to make pauses between.
At the same time stepper2 do something equivalent
Here are the pins i use
stepper1(7, 8);
stepper2(9,10);
const int dirPin = 8;
const int stepPin = 7;
const int dirPin = 10;
const int stepPin = 9;
const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int limswitch1 = 5;
const int limswitch2 = 6;
I don't think the Stepper library is suitable for a DRV8825 which just requires step and direction signals. The AccelStepper library does work with them if you use the DRIVER option.
This Simple Stepper Code should get the motors going and does not need any library.
If you have more questions please post a link to the datasheet for your motors.
Thanks for your answer. i already use accelstepper liblary and the motors are moving.
i dont know how to do what i want because i dont know cc++.
the link you attached was helpfull enough but i still dont have it...
Sure, add in reading of buttons and make a decision based on them.
// before setup()
byte button2 = 2; // button on pin 2, wired to connect to GND when pressed
// in setup():
pinMode (button2, INPUT_PULLUP);
// in loop():
if (digitalRead(button2) == LOW){
// take some action
}
this turn motor1 left and motor 2 right and stay for 3seconds
is it possible someone to tell me how i can
turn motor1 left and motor2 right and stay for 3seconds
and then turn motor1 right and motor2 left and stay for 7seconds
Thanks
Certainly smileys have no part in it. Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum
Have a look at how timing is managed using millis() in the demo Several Things at a Time. In simple terms you need to record the time (the value of millis() ) when your motors complete the first move and then regularly check the latest value of millis() until 3 seconds (or whatever) have elapsed.
DO NOT use delay() because the stepper.run() function must be called as often as possible.
Also have a look at how to organize your code into functions in Planning and Implementing a Program. If you organize your code that way it will make it much easier to manage and to add features.