// defines pins numbers
const int stepPin = 15;
const int dirPin = 2;
int count=10;
void setup() {
// Sets the two pins as Outputs
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
while(count>0){
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
Serial.println("Clockwise");
for(int x = 0; x < 20; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000); // One second delay
digitalWrite(dirPin,LOW); //Changes the rotations direction
Serial.println("AntiClockwise");
for(int x = 0; x < 20; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000);
count-=1;
}
}
void loop() {
}