char val; // Data received from the serial port const int Ystep_pin = 22; //defining pin connected to step pin of motor driver const int Ydir_pin = 23; //defining pin connected to direction pin of motor driver int delayBetweenSteps = 100; //this defines how fast it moves void setup() { Serial.begin(9600); // Start serial communication at 115200 bps pinMode(Ystep_pin, OUTPUT); //saying the pin is for output pinMode(Ydir_pin, OUTPUT); //saying the pin is for output } void loop() { while (Serial.available()) { // If data is available to read, val = Serial.read(); // read it and store it in val } if (val == 'H') { // If H was received digitalWrite(Ydir_pin, HIGH); //Yr_direction pin to be rotate one way } else { //if anything eles digitalWrite(Ydir_pin, LOW); //Yr_direction pin to be rotate another way } digitalWrite(Ystep_pin, HIGH); //step to hight delayMicroseconds(delayBetweenSteps); //delay between steps digitalWrite(Ystep_pin, LOW); // step to low delayMicroseconds(delayBetweenSteps); //delay between steps //code avobe saying continue rotating in certain speed }