Cnc Plotter with Adafruit Motorshield V2

Hi there!
I've got the following problem and hopefully, somebody of you guys could help me out. :slight_smile:

I'm working on a CNC Plotter machine. I'm using the Arduino Uno and two Adafruit Motorshields V2. For the motors, i'm using the normal adafruit steppers with 200 steps.

Everything allright and i've got no problem with the mechanics or how to run the steppers.

My Question is about the code: How is it possible to run the two steppers at the same time. I've googled a lot but i didn't find something helpful to me.:confused: It's no problem for me to run one stepper, but i'm not getting how to run two at the same time. I tried it also with the accel stepper library. It worked, but the steppers were rotating only one step. Thats not very helpful for my project...

Is there maybe a way to run the steppers with the accel stepper library, more than one step at the same time? Or is it even possible to use a CNC Plotter software with the Adafruit shield? So that i can draw, what i would like to Plot, if you know what i mean...

Hopefully anybody could help me out, i would be very very grateful for that. Thanks for your time guys!:slight_smile:

The motorshields are not a good choice for controlling stepper motors and may limit the performance you caan get. Have a look at Stepper Motor Basics

I don't understand why you have doubts about the ability to control 2 stepper motors? It should be just as easy as running 1 motor.

If you use the AccelStepper library you can create two instances, say myStepperA and myStepperB and run them both with;;

The AccelStepper library is not intended for the co-ordinated movement of two motors - for example where one is expected to do 112 steps in the time the other should do 401 steps.

I believe the MultiStepper library (from the same source) can do that but I have no experience of it. I have written my own code to control 3 motors on a small lathe - very similar to this Simple Stepper Code.


Thanks very much for your answer!

Could you maybe send me the code of what you mean? Because i dont get it 100%... :confused:

That would be very Kind:)

Could you maybe send me the code of what you mean? Because i dont get it 100%... :confused:

Did you study the code I gave a link to?

I don't understand what you don't understand. If you explain I will try to help.


#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"
#include <Servo.h>

Adafruit_MotorShield AFMSbot(0x61); 
Adafruit_MotorShield AFMStop(0x60); 

Adafruit_StepperMotor *myStepper1 = AFMSbot.getStepper(200, 1);
Adafruit_StepperMotor *myStepper2 = AFMSbot.getStepper(200, 2);

void step1() {  
  myStepper1->step(400, FORWARD, DOUBLE);
void step12() {  
  myStepper1->step(400, BACKWARD, DOUBLE);
void step2() {  
  myStepper2->step(400, FORWARD, DOUBLE);
void step22() {  
  myStepper2->step(400, BACKWARD, DOUBLE);

AccelStepper stepper1(step1, step12);
AccelStepper stepper2(step2, step22);

Servo myServo;
int angle = 0;

void setup(){

void loop(){

    if (stepper1.distanceToGo() == 0)

    if (stepper2.distanceToGo() == 0)

   for(angle=0; angle < 180; angle += 1) {               
   for(angle=180; angle >= 1; angle -= 1){

Im using this code, but the Steppers are only rotating 1 STEP! :confused:
I would like to know, how i have to change the code to get the Steppers rotating f.e. 200 steps
I think your code is good for your Motor Board but i dont think it works with my board…

(Im using also a servo...)
But the code parts for the servo are working...

I know, that im using the method "onestep", but the code is not working with another method...

I would like to help but the truth is I have no idea what those Adafruit libraries do. They seem to me to make simple things complex.


Thanks anyway bro:)