Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
I'm currently trying to build a 3d scanner with a garmin v3, sparkfun motors, a4988, and an Arduino Uno. However, currently, my sparkfun stepper motors, which are driven by A4988, switch directions every step. I'm not sure why this issue occurs, and sometimes the stepper motors steps properly, but 95% of the time, the stepper switches direction every step. I'm currently micro stepping by 1/16, but when the oscillation occurs, it appears to be taken over 1 step every oscillation cycle. Here is a link to a video of this issue:
LIDARLite myLidarLite; const int dirPinV = 2;Â // Direction const int stepPinV = 3; // Step const int dirPinH = 4;Â // Direction const int stepPinH = 5; // Step
// Motor steps per rotation
void setup() {  Serial.begin(115200);  myLidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz  myLidarLite.configure(0); // Change this number to try out alternate configurations
 // Setup the pins as Outputs  pinMode(stepPinV,OUTPUT);  pinMode(dirPinV,OUTPUT);  pinMode(stepPinH,OUTPUT);  pinMode(dirPinH,OUTPUT);
 pinMode(8,OUTPUT);  pinMode(9,OUTPUT);  pinMode(10,OUTPUT);
 pinMode(11,OUTPUT);  pinMode(12,OUTPUT);  pinMode(13,OUTPUT);
 digitalWrite(8,HIGH);  digitalWrite(9,HIGH);  digitalWrite(10,HIGH);
 digitalWrite(11,HIGH);  digitalWrite(12,HIGH);  digitalWrite(13,HIGH);
} void loop() { Â int maxStepV = 45*16; Â int stepV = 1;
 int maxStepH = 60*16;  int stepH = 1;  for (int x = 0; x < maxStepH; x = x + stepH*2)  {   // Set motor direction clockwise   digitalWrite(dirPinV,HIGH);   // Spin vertical   for(int v = 0; v <= maxStepV; v= v + stepV) {    digitalWrite(stepPinV,HIGH);    delayMicroseconds(500);    digitalWrite(stepPinV,LOW);    delayMicroseconds(500);    Serial.println(myLidarLite.distance(false));   }   // Pause for one second   delay(1000);
  // Spin horizontal   digitalWrite(dirPinH,HIGH);   for(int hstep = 0; hstep <= stepH; hstep= hstep + stepH) {    digitalWrite(stepPinH,HIGH);    delayMicroseconds(10000);    digitalWrite(stepPinH,LOW);    delayMicroseconds(10000);   }   myLidarLite.distance(true);
  // Pause for one second   delay(1000);
  // spin vertical   digitalWrite(dirPinV,LOW);   // Spin motor two rotations quickly   for(int v = 0; v <= maxStepV; v= v + stepV) {    digitalWrite(stepPinV,HIGH);    delayMicroseconds(500);    digitalWrite(stepPinV,LOW);    delayMicroseconds(500);    Serial.println(myLidarLite.distance(false));   }   // Pause for one second   delay(1000);
  // Spin horizontal   digitalWrite(dirPinH,HIGH);   for(int hstep = 0; hstep <= stepH; hstep= hstep + stepH) {    digitalWrite(stepPinH,HIGH);    delayMicroseconds(10000);    digitalWrite(stepPinH,LOW);    delayMicroseconds(10000);   }   myLidarLite.distance(true);   // Pause for one second   delay(1000);  } }
This looks like a very cool project (I hope you don't mind I embedded your video)!
Unfortunately my experiences with stepper motors is pretty much zero - I know how they work, just never got around playing with them. Since this is a little over my head, I'd recommend (which you probably already did) reading this section Arduino Stepper Library on the Arduino website and start with some barebones experiments. I'd also start dumping the variables like stepH and such to the serial monitor to see if there is a mistake in the logic (happens to me at times as well haha).
Like I said: I'm pretty sure you've already done all that. But unfortunately, I do not know enough about stepper motors and such to be of any useful help 😞 .
Maybe one of the other users here can chime in ...
I don't have any experience with stepper motors but I am wondering if the issue is related to the pins you are using. Great idea to include a video.Â
You are using pins 11, 12 and 13. On the Arduino Uno these are for SPI commucation. Pin 11 is MOSI, 12 is MISO and 13 is SCK. I don't think you can override this function.
Ulvenhout.com My home town ... Ulvenhout in the Netherlands (Noord Brabant)
MalwareBytes Probably one of the best tools to prevent and remove all kinds of malware and viruses on Windows and MacOS X.
VLC - VideoLAN Media Player One of the most flexible media players around and available on multiple computer platforms. Handles pretty much any audio and video type available and plays DVD as well.
Start-is-Back Ultimate Start-button replacement for Windows 8 and 8.1 - Super cheap, but highly recommended.
Kubuntu Kubuntu is a Ubuntu variant that use KDE as it's desktop manager. Fast and well supported.
Links Page These and more of our favorite links can be found on the Links Page.
New Downloads
RenameMyTVSeries-2.3.2-QT5-Linux-x64-static-ffmpeg.tar.xzDate: 2025-07-10 - Size: 78.3 MBRename My TV Series, for Linux (64 bit QT5), a tool to assist in renaming TV Show episode files. This bundle comews with rather large static builds of ffmpeg and ffprobe.
RenameMyTVSeries-2.3.2-QT5-Linux-x64-shared-ffmpeg.tar.xzDate: 2025-07-10 - Size: 1.9 MBRename My TV Series, for Linux (64 bit QT5), a tool to assist in renaming TV Show episode files. This bundle relies on ffmpeg and ffprobe shared libraries on your system.
RenameMyTVSeries-2.3.2-GTK-Linux-x64-static-ffmpeg.tar.xzDate: 2025-07-10 - Size: 78.3 MBRename My TV Series, for Linux (64 bit GTK), a tool to assist in renaming TV Show episode files. This bundle comes with (large) static builds of ffmpeg and ffprobe.
RenameMyTVSeries-2.3.2-GTK-Linux-x64-shared-ffmpeg.tar.xzDate: 2025-07-10 - Size: 1.9 MBRename My TV Series, for Linux (64 bit GTK), a tool to assist in renaming TV Show episode files. This bundle relies on ffmpeg and ffprobe shared libraries on your system.
RenameMyTVSeries-2.3.2-Windows-x64-setup.exeDate: 2025-07-10 - Size: 48.8 MBRename My TV Series, for Windows (Intel 64 bit), a tool to assist in renaming TV Show episode files. Static builds of ffmpeg and ffprobe are included.
RenameMyTVSeries-2.3.2-macOS-Universal.dmgDate: 2025-07-10 - Size: 98.5 MBRename My TV Series, for macOS (Universal binary for Apple Silicon ARM and Intel 64 bit), a tool to assist in renaming TV Show episode files. Static universal binary builds of ffmpeg and ffprobe are included.
Downloads Page Find these and more Downloads on the Downloads Page, where you will also find articles references, operating system requirements and categories.
Amazon Ads
Support us by doing your shopping at Amazon.com, either click the link, or click one of the links below …
You can also sponsor us through these Amazon offerings:
Please consider disabling your ad blocker for our website.We rely on these ads to be able to run our website.You can of course support us in other ways (see Support Us on the left).