Hi there
Can someone help please. I am tearing my hair out in frustration. I cannot see what I am donig wrong.
I need the While (steps) loop in following to repat "Divs" times I have tried IF For While loops to no avail. Help please.
int Divs=0;
int Dir=0;
int Steps=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(2,OUTPUT);//Steps
pinMode(3,OUTPUT);//Dir
}
void loop() {
Serial.println ("Enter Number of Divisions");
while (!Serial.available()) {//wait for data
}
Divs = Serial.parseInt();//assign serial data to Divs
Serial.println(Divs);
Steps =(1600/Divs);//make steps = to 1600(number of microsteps)/Divs
if (Divs>=0){
while (Steps>=0){
Serial.println(Steps);
digitalWrite(2,HIGH);
digitalWrite(2,LOW);
Steps=Steps-1;
Divs=Divs-1;
}
}
}
Thank you in advance
Bob
ok i have found it