/* BYJ48 Stepper motor code Connect : IN1 >> D8 IN2 >> D9 IN3 >> D10 IN4 >> D11 VCC ... 5V Prefer to use external 5V Source Gnd 7/2/2021 */ #define IN1 8 #define IN2 9 #define IN3 10 #define IN4 11 int Steps = 0; boolean Direction = true;// gre unsigned long last_time; unsigned long currentMillis ; int steps_left=0; long time; void setup() { Serial.begin(115200); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT); // delay(727); } void loop() { while(steps_left>0){ currentMillis = micros(); if(currentMillis-last_time>=1000){ stepper(1); time=time+micros()-last_time; last_time=micros(); steps_left--; } } Serial.println(time); Serial.println("Wait...!"); delay(727); Direction=!Direction; steps_left=273; } void stepper(int xw){ for (int x=0;x7){Steps=0;} if(Steps<0){Steps=7; } }