Stepper Motor

Hi everyone,
I posted a message on this forum few weeks ago about how to make a stepper motor rotate according to the values assigned from a dialog Box. I managed to write a code but i don’t know whether it will work. What i want is to enter the direction from the dialog box and the value. But i have one problem. My teacher wants the final position of the arduino to be sent to the dialog box. For example at first we enter 100steps in the forward direction. Then we enter 40steps in the backward direction. The final position will be 60steps. Does anyone know how to write that code?
Thanks

#include <Stepper.h>
int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int DRpin = 9;
int DR;

Stepper motor(512, in1Pin, in2Pin, in3Pin, DRpin);
void setup()
{
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(in3Pin, OUTPUT);
pinMode(DRpin, OUTPUT);
// this line delays the serial interface
// until the terminal window is opened
while (!Serial);
Serial.begin(9600);
motor.setSpeed(20);
}
void loop()
{
if (Serial.available())
{
delay(25);
int steps = Serial.parseInt();
DR= Serial.read();
DR= DR - ‘0’;
if(DR = ‘1’){
digitalWrite(DRpin, HIGH);
motor.step(steps);
//Serial.println(steps);
}
else if(DR = ‘2’){
digitalWrite(DRpin, LOW);
motor.step(-steps);
// Serial.println( " -steps");
}
}
}

Moussou: For example at first we enter 100steps in the forward direction. Then we enter 40steps in the backward direction. The final position will be 60steps. Does anyone know how to write that code?

Just have a variable to keep track of the currentStepperPosition

currentStepperPosition += numSteps;

assuming numSteps = 100 or -60 as the case may be.

...R

This doesn't seem correct.

DR= Serial.read();
DR= DR - '0'; //turns an ASCII character into a number
if(DR = '1'){ //You're assigning an ASCII character to DR here!!!

It should be:

if(DR==1){

Also, it's convention to give [u]constants[/u] all CAPS names. Variables start with a lower case letter.

thank you :)