Why doesn't this code work (stepper motor)?

hi everone..
A few weeks ago, I made wrote some code to provide basic serial communication between the arduino and PC. Basically, it waits for 'packets' of data. The packet markers are < and > and the text is sent as ascii encoded values. In the original version of the program, I could control the brightness of an LED (by PWM) by sending values to the arduino over serial.

//SOP marker is '<'
//EOP marker is '>'
String inData;
char inChar;
boolean start_received = false;
char conv_buffer[4];
int output;

void setup(){
  Serial.begin(9600);
  pinMode(9,OUTPUT);
}

void loop(){
  //While there is at least one byte to be read,
  while (Serial.available()>= 1)
  {
    inChar = Serial.read();
    if (inChar == '<')
    {
      start_received = true;
      continue;
    }
    
    else if (inChar == '>')
    {
      Serial.println(inData);
      //Conver the string to chararray and then to an int
      inData.toCharArray(conv_buffer,4);
      output = atoi(conv_buffer);
      analogWrite(9,output); //output to the LED on pin 9
      
      //reset for next packet
      start_received = false;
      inData = "";
      break;
    }
    
    else if(start_received)
    {
      inData.concat(inChar);
    }
  }
}

I tried to use this program to control a stepper motor by modifying it as follows.

#include <Stepper.h>
Stepper myStepper(96,8,9);

//SOP marker is '<'
//EOP marker is '>'
String inData;
char inChar;
boolean start_received = false;
char conv_buffer[4];
int output;

void setup(){
  Serial.begin(9600);
  pinMode(9,OUTPUT);
}

void loop(){
  //While there is at least one byte to be read,
  while (Serial.available()>= 1)
  {
    inChar = Serial.read();
    if (inChar == '<')
    {
      start_received = true;
      continue;
    }
    
    else if (inChar == '>')
    {
      Serial.println(inData);
      //Conver the string to chararray and then to an int
      inData.toCharArray(conv_buffer,4);
      output = atoi(conv_buffer);
      myStepper.step(output);  //This is the only change to the code, except for the include statement and the stepper initializer.
      
      //reset for next packet
      start_received = false;
      inData = "";
      break;
    }
    
    else if(start_received)
    {
      inData.concat(inChar);
    }
  }
}

However, for any value, the stepper just makes one step and stops. Why is this?

(The stepper works properly with the Demo sketches that come with the IDE.. )

      continue;

Why?

However, for any value, the stepper just makes one step and stops. Why is this?

We have no idea what you are sending the function, what ends up in inData, what conv_buffer looks like, or what output contains.

If the extracted char array is really only 3 characters long, why are you using a String object?

Sorry I wansn't able to reply sooner..

You're right.. I don't know why I put a "continue" statement in there.. maybe it was left over from some debugging.

As for the contents of the variables,
the inputs I gave were something like '<9>' or '<20>'. To check that "output" was an int, I tried multiplying it by 2 and printing the result out to serial. There weren't any errors, so I assume that means output is, in fact, and int.

PaulS:
If the extracted char array is really only 3 characters long, why are you using a String object?

I didn't really put much thought into selecting the type of varialbe..

To check that "output" was an int, I tried multiplying it by 2 and printing the result out to serial. There weren't any errors, so I assume that means output is, in fact, and int.

That the contents of a memory address could be multiplied by 2 and printed to the serial monitor doesn't tell you anything about the validity of the contents of that memory location. If you send <0> and you see 0 on the serial monitor, you might assume that output is indeed populated correctly. If the stepper motor then steps once, you should be concerned that there is still a problem.

If you send <99> and see 198 on the serial monitor, that tells you one thing. If you see some other value, that tells you something else.

You didn't tell us what you saw, so I guess you no longer need help.

...well, i got the correct values.
for example,when i entered <24> I got 48 as the output..

So, valid data leads to a valid value in output. If the stepper motor is not stepping correctly, the issue is not with the serial input/processing. It must lie elsewhere.

Add Serial.print() statements to the Stepper library. Make sure that the number of steps to step is correct in the step() method. If it is, but the motor doesn't step correctly, the problem is hardware.

The stepper works properly with the Demo sketches that come with the IDE.

All the examples are for a 4 wire stepper. Your code assumes a 2 wire stepper. Please explain why, if the 4 wire examples work, you are using only two wires in your sketch.

Yes..I modified the code to work with the two pin configuration..

Before you can code as mpu to emulate motor drive hardware, you might be best to read the stepper controller pdf for the L297, the companion to the L298 used on the Motor3 Shield. By the way the schematic for the Motor3 shows the wrong logic symbol for the 4077. It is a 2 input XNOR Gate, not the depicted 2 input NAND Gate.

It shows a complete example circuit as well as the internal logic diagrams.