Here is code and sorry about the St up
[code]
//\DEMO FOR DIFFERENT FUNCTION
/**ENABLE TO BE USED ADD BUTTON TO BOTTOM
SparkFun Easy Driver Basic Demo
Toni Klopfenstein @ SparkFun Electronics
March 2015
https://github.com/sparkfun/Easy_Driver
Simple demo sketch to demonstrate how 5 digital pins can drive a bipolar stepper motor,
using the Easy Driver (https://www.sparkfun.com/products/12779). Also shows the ability to change
Example based off of demos by Brian Schmalz (designer of the Easy Driver).
http://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html
******************************************************************************/
//Declare pin functions on Redboard
#define stp 2
#define dir 3
#define MS1 4
#define MS2 5
#define EN 6
//Declare variables for functions
char user_input;
int x;
int state;
void setup() {
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
pinMode(MS1, OUTPUT);
pinMode(MS2, OUTPUT);
pinMode(EN, OUTPUT);
resetEDPins(); //Set step, direction, microstep and enable pins to default states
Serial.begin(9600); //Open Serial connection for debugging
Serial.println();
//Print function list for user selection
Serial.println("Enter number :");
Serial.println("1. START AND RUN .");
Serial.println();
}
//Main loop
void loop() {
while (Serial.available()) {
user_input = Serial.read(); //Read user input and trigger appropriate function
digitalWrite(EN, LOW); //Pull enable pin low to allow motor control THIS CAN BE USED TO START AND STOP
if (user_input == '1');
StepForwardDefault();
}
{
{
}
{
}
resetEDPins();
}
}
//Reset Easy Driver pins to default states
void resetEDPins()
{
digitalWrite(stp, LOW);
digitalWrite(dir, LOW);
digitalWrite(MS1, LOW);
digitalWrite(MS2, LOW);
digitalWrite(EN, HIGH);
}
//Default microstep mode function
void StepForwardDefault()
{
Serial.println("Moving forward at default step mode.");
digitalWrite(dir, LOW); //Pull direction pin low to move "forward"
for (x = 1; x < 10000; x++) //Loop the forward stepping enough times for motion to be visible
{
digitalWrite(stp, HIGH); //Trigger one step forward
delay(1);
digitalWrite(stp, LOW); //Pull step pin low so it can be triggered again
delay(1);
}
}