Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "AccelStepperSpark/AccelStepperSpark.h"
- // Define the steppers/drivers and the step/dir pins used
- AccelStepper stepperSmall(AccelStepper::DRIVER, D5, D4);
- // Define Microstepping pins
- #define MODE0 D0
- #define MODE1 D1
- #define MODE2 D2
- int pos = 1200;
- void setup()
- {
- /*
- Micrstepping table for the DRV8825
- ----------------------------------
- MODE0 MODE1 MODE2 MICROSTEP RESOLUTION
- ===== ===== ===== ====================
- Low Low Low Full step
- High Low Low Half step
- Low High Low 1/4 step
- High High Low 1/8 step
- Low Low High 1/16 step
- High Low High 1/32 step
- Low High High 1/32 step
- High High High 1/32 step
- */
- pinMode(MODE0, OUTPUT);
- pinMode(MODE1, OUTPUT);
- pinMode(MODE2, OUTPUT);
- digitalWrite(MODE0, LOW);
- digitalWrite(MODE1, LOW);
- digitalWrite(MODE2, LOW);
- stepperSmall.setMaxSpeed(800.0);
- stepperSmall.setAcceleration(200.0);
- stepperSmall.setSpeed(400);
- }
- void loop()
- {
- if (stepperSmall.distanceToGo() == 0)
- {
- delay(500);
- pos = -pos;
- stepperSmall.moveTo(pos);
- }
- stepperSmall.run();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement