SETUP STEPPER MOTOR BY L293D

StepperL293D

#include <Stepper.h>

int in1Pin = 12;

int in2Pin = 11;

int in3Pin = 10;

int in4Pin = 9;

Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);

void setup()

{

pinMode(in1Pin, OUTPUT);

pinMode(in2Pin, OUTPUT);

pinMode(in3Pin, OUTPUT);

pinMode(in4Pin, OUTPUT);

// this line is for Leonardo’s, it delays the serial interface

// until the terminal window is opened

while (!Serial);

Serial.begin(9600);

motor.setSpeed(25);

}

void loop()

{

if (Serial.available())

{

int steps = Serial.parseInt();

motor.step(steps);

}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s