AccelStepperDist CNC — Arduino Uno simulation

An interactive Arduino Uno circuit simulation you can run free in your browser on Velxio, by leemcf.

Components

Sketch code

#include <AccelStepper.h>
#include <AccelStepperWithDistance.h>

AccelStepperWithDistance stepper(AccelStepperWithDistance::DRIVER, 13, 12);
const float eng=11;


void setup(){
Serial.begin(9600);
stepper.setMaxSpeed(200); //SPEED = Steps / second
stepper.setAcceleration(100); //ACCELERATION = Steps /(second)^2
stepper.setStepsPerRotation(200);  // For a 1.8° stepper motor
stepper.setDistancePerRotation(1.5); // If one rotation moves 8mm

digitalWrite(eng, LOW);
pinMode(2, INPUT_PULLUP); // internal pullup resistor (debouncing)
attachInterrupt(digitalPinToInterrupt(2), stopper, HIGH);

stepper.runToNewDistance(20);
}

void loop(){
    stepper.run();
    
}

void stopper(){
    digitalWrite(eng, HIGH);
    Serial.println("stop");
}

More projects by leemcf