Stepper motor with L293D

Hello together,

I want to build a camera slide with a belt, which is powered with a stepper motor. I am using the L293D as a driver. I want to keep the program as simple as possible.

On each side of the slide there should be button which should change the direction of the stepper when the button is touched by the sled. I tried a lot of different ways but I don’t know how to continue. Maybe some of you could help me and I would appreciate that very much.

I will copy my current code in here that u can see what I tried. I know that it is a little bit unclean.

Thanks in Advance
Lukas :slight_smile:

#include <Stepper.h>

//int inlPin = 13;
const int stepsU = 200;

//Taster Start-Stop
const int pin_start = 2;
const int interrupt_stop = 3;

//Variablen
volatile bool taster_start = LOW;
volatile bool taster_stop = LOW;
int i, k = 0;


Stepper myStepper(stepsU,9,10,11,12);

void setup()
 {
   //pinMode(inlPin, OUTPUT);
   myStepper.setSpeed(100);
   
   pinMode(pin_start, INPUT_PULLUP);  
   
   pinMode(interrupt_stop, INPUT_PULLUP);
   attachInterrupt(digitalPinToInterrupt(interrupt_stop), STOP, CHANGE);

 }

void loop()
 {
   taster_start = !digitalRead(pin_start);
   taster_stop = !digitalRead(interrupt_stop);

   
   i = 0;
   if (taster_start){
     do{
       myStepper.step(HIGH);
      
       //if (taster_stop){
        // return 0;               
      // }
       i++;
     } while (i < 1000);
     i = 0;
   }
   /*if (interrupt_stop){
     myStepper.step(-HIGH);
   }*/
 }

void STOP(){
 myStepper.step(HIGH);

}

HowLuu:
Hello together,

I want to build a camera slide with a belt, which is powered with a stepper motor. I am using the L293D as a driver.

Firstly you've provided no links for the exact hardware you have, and secondly most steppers are
drivable by H-bridges like the L293D, they need stepper drivers.

You have not told us what your program actually does and what you want it to do that is different.

Please also post a link to the datasheet for your stepper motor.

...R
Stepper Motor Basics
Simple Stepper Code