Been trying for 2 days to get my 28BYJ-48 unipol stepper to turn 210 times pause for about a second then reverse 210 revolutions on the output shaft.
I,m using the ULN2003 connected to arduino uno board all on 5volts, I have tried the libraries but cant seem to make it happen, is there a simple copy and paste code someone can give me as I,m not a coder just a hobbyist & newcomer
Thanks dave
heres my code & I am using only one stepper motor .....
/* YourDuinoStarter Example: 2 Stepper Motors
- WHAT IT DOES: Runs 2 28BYJ-48 stepper motors with AccelStepper Library
- Motors accelerate and decelerate simultaneously in opposite rotations
- SEE the comments after "//" on each line below
- Derived from example code by Mike McCauley
- modified by Celem for single stepper
- modified by lowres for two steppers
NOTE: This may not run 2 motors from USB.
May need separate +5 Supply for motors
- CONNECTIONS: See Pin definitions below
- V1.01 11/30/2013
Questions: terry@yourduino.com */
/*-----( Import needed libraries )-----*/
#include <AccelStepper.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define FULLSTEP 4
#define HALFSTEP 8
// motor pins
#define motorPin1 4 // Blue - 28BYJ48 pin 1
#define motorPin2 5 // Pink - 28BYJ48 pin 2
#define motorPin3 6 // Yellow - 28BYJ48 pin 3
#define motorPin4 7 // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)
#define motorPin5 8 // Blue - 28BYJ48 pin 1
#define motorPin6 9 // Pink - 28BYJ48 pin 2
#define motorPin7 10 // Yellow - 28BYJ48 pin 3
#define motorPin8 11 // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)
/*-----( Declare objects )-----*/
// NOTE: The sequence 1-3-2-4 is required for proper sequencing of 28BYJ48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
AccelStepper stepper2(HALFSTEP, motorPin5, motorPin7, motorPin6, motorPin8);
/*-----( Declare Variables )-----*/
//none
void setup() /****** SETUP: RUNS ONCE ******/
{
stepper1.setMaxSpeed(1000.0);
stepper1.setAcceleration(50.0);
stepper1.setSpeed(200);
stepper1.moveTo(430080); // 1 revolution
stepper2.setMaxSpeed(1000.0);
stepper2.setAcceleration(50.0);
stepper2.setSpeed(200);
stepper2.moveTo(-430080); // 1 revolution
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
//Change direction at the limits
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
if (stepper2.distanceToGo() == 0)
stepper2.moveTo(-stepper2.currentPosition());
stepper1.run();
stepper2.run();
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
//none
//*********( THE END )***********