L293D stepper shield CNC - Questions about code


Trying to build CNC with Arduino UNO and L293D shield from Adafruit. So, far I have been able to run it with the code mentioned below. The video can be watched here. So, it establishes that wiring is okay. (Please note that I am using old DVD drives motors and I don’t have data sheet, so step value of ‘200’ etc. is all guess.). DVD ROM is Samsung CD-RW/DVD DRIVE SM-308.

#include <AFMotor.h>

AF_Stepper motor(200, 1);
void setup() 

  Serial.begin(9600);           // set up Serial library at 9600 bps  
  Serial.println("Stepper test!");  
  motor.setSpeed(150);  // 100 rpm     


void loop() 

  motor.step(250, BACKWARD, SINGLE); 
  motor.step(250, FORWARD, SINGLE);

However, to enable Jog and for use with Processing, I use the modified code (used by everyone who made CNC plotter.). Even though the serial monitor shows that it’s connected, see screenshot, When I try to move using G1 Y20 or G1 Y-20 etc. in the serial monitor of Arduino, the motor does not move. The same thing happens when I try to do so it with Processing though it connects.

I changed the values like ‘MICROSTEP’ to "SINGLE’ and Speed values and other values too since it worked with the test sketch. Can I do it, without any issues? I am not able to wrap my head around it, what am I doing wrong and need help with programming side of it. Or atleast a direction in which you can point me. (Original codes that I found online that worked for most people have been attached too, along with ones I tried.

I also tried the original Arduino Code, with that the motor moves when in Arduino serial monitor, but in Processing, it hums when on certain Jog values (0.1inches), on others, does nothing.


CNC_code.ino (9.54 KB)

GCTRL.pde (4.04 KB)

ThecodeItried.ino (9.53 KB)

I use the modified code (used by everyone who made CNC plotter.).

That code you haven't shown us. If you are sending those strings from Processing, you should be able, on the Arduino, to write to the serial port, and, in Processing, read from the serial port, to know that what you sent it what was received, or not.