CODE
//Subscribe My Channel **TECH TECHNOLOGY PK**
#include <Stepper.h>
const int stepsPerRevolution = 5;// change this to fit the number of steps per revolution
// for your motor
int estado= 0;
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
// set the speed amt 30m rpm:
myStepper.setSpeed(500);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0){
estado = Serial.read(); }
// step one revolution in one direction:
if (estado =='1'){
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
}
// step one revolution in the other direction:
if (estado =='3'){
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
}
if (estado == 'A')
myStepper.setSpeed(1500);
if (estado == 'B')
myStepper.setSpeed(2000);
if (estado == 'C')
myStepper.setSpeed(2500);
if (estado == 'D')
myStepper.setSpeed(3000);
if (estado == 'E')
myStepper.setSpeed(3500);
if (estado == 'F')
myStepper.setSpeed(4000);
}