Can a stepper motor go in reverse

How would I change this code to make the stepper motor go in reverse?

#include <Stepper.h>

int in1Pin = 8;
int in2Pin = 9;
int in3Pin = 10;
int in4Pin = 11;

Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);

void setup()
{
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(in3Pin, OUTPUT);
pinMode(in4Pin, OUTPUT);

// this line is for Leonardo's, it delays the serial interface
// until the terminal window is opened
while (!Serial);

Serial.begin(9600);
motor.setSpeed(20);
}

void loop()
{
if (Serial.available())
{
int steps = Serial.parseInt();
motor.step(steps);
}
}

Basically, you would have to set steps to a negative number. But I'm sure someone will be along to give you a more thourough explanation.

Hi, Always start with the DOCUMENTATION...

See: Stepper - Arduino Reference

You would find:

steps: the number of steps to turn the motor - positive to turn one direction, negative to turn the other (int)

Serial.parseInt() can parse negative numbers. Just type in a negative number.