String command;
#define stepPin 4
#define dirPin 3
void setup() {
Serial.begin(9600);
Serial.println("Please entre location (A/B/C)");
}
void loop() {
if(Serial.available()){
command = Serial.readStringUntil('\n');
if(command.equals("A"))
{
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 400; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500); // by changing this time delay between the steps we can change the rotation speed
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
else if(command.equals("B"))
{
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 800; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500); // by changing this time delay between the steps we can change the rotation speed
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
else if(command.equals("C"))
{
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 1200; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500); // by changing this time delay between the steps we can change the rotation speed
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
}
}