You didn't use the if statement the way you needed to - no semicolon at end of it statement, and missing open/close braces.
void loop() {
if (digitalRead(buttonPin)==LOW) // removed semicolon
{ // added open brace
myStepper.step(stepsPerRevolution);
delay(1000);
myStepper.step(-stepsPerRevolution);
delay(1000);
} // added closing brace
}
A couple things that may me helpful to you. I am a novice Adruino programmer, so there may be other helpful stuff others can teach us.
At the top of the Adruino sketch program (the program you enter your code into, process, and download with) click on Tools, then Auto Format. This will apply indentation to your code to help you make sure you have open/close braces, and see better what code is going to be executed within the open/close braces. For example, your code I modified above, after Auto Format, would appear like this:
void loop() {
if (digitalRead(buttonPin)==LOW) // removed semicolon
{ // added open brace
myStepper.step(stepsPerRevolution);
delay(1000);
myStepper.step(-stepsPerRevolution);
delay(1000);
} // added closing brace
}
As you can see, the Auto Format makes you program a bit more readable and can assist in finding problems.
The second thing that you may already know, is that you can click on Help, then click Reference. This will open a browser with a page of all the Arduino programming language statements. You than click on the statement you want more info on, and you get a page describing what and how to use for that statement. I usually right click on the statement I am interested in, then click Open link in new tab. I do this because I usually need two or three statements that I can quickly go back and forth between.
I know this code is very short, but I was always taught by "professional" programmers that you can't have enough comments. They help you remember what you programmed, and maybe why you programmed it. Comments can help others understand what/why you of your program, and help them help you figure out what me be going awry. // can definitely be your friend.
Hope these may be of some help!!!!