Question: To our project we use this code in arduino shown below, Its to move the stepper motor for a desired steps(pulses) The problem of this

To our project we use this code in arduino shown below,
Its to move the stepper motor for a desired steps(pulses)
The problem of this code is that it move right after we turn on the power source that connecting to the arduino, and we need to modify it to make it move after we give a command in command window to start the movement. Please help if you know how to modify it to our purpose( maybe with sirial monitor?) or give as any suggestions how to modify it ( to make the code start when only we command the code to start)
the code:

const int stepPin = 5;

const int dirPin = 2;

const int enPin = 8;

void setup() {

pinMode(stepPin,OUTPUT);

pinMode(dirPin,OUTPUT);

pinMode(enPin,OUTPUT);

digitalWrite(enPin,LOW);

}

void loop() {

digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction

for(int x = 0; x

digitalWrite(stepPin,HIGH);

delayMicroseconds(500);

digitalWrite(stepPin,LOW);

delayMicroseconds(500);

}

delay(1000); // One second delay

digitalWrite(dirPin,LOW); //Changes the direction of rotation

for(int x = 0; x

digitalWrite(stepPin,HIGH);

delayMicroseconds(500);

digitalWrite(stepPin,LOW);

delayMicroseconds(500);

}

delay(1000);

}

 To our project we use this code in arduino shown below,

sketch_dec19a 1 rold logp(b t digitaiwrite (dirpin, HIOH); // Enables the motor to move 1n a particular direction for (1ntx=0;x

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!