what about something like
int step;
unsigned long usecLst;
void loop ()
{
if (step) {
unsigned long usec = micros ();
if (usec - usecLst >= stepSpeed) {
usecLst = usec;
if (LOW == digitalRead (stepPin))
digitalWrite (stepPin, HIGH);
else {
digitalWrite (stepPin, LOW);
step--;
}
}
}
// read temp values
if (millis () - lastReading >= interval) {
temperatureReadings ();
lastReading = millis ();
}
// check if the user has entered any input
if (Serial.available ()) {
char buf [80];
int n = Serial.readBytesUntil ('\n', buf, sizeof (buf)-1);
buf [n] = '\0';
if ('s' == buf [0]) {
sscanf (buf, "s%d", &step);
Serial.println (step);
}
}
}