Stepper motor spinning all the time

I am using this driver A4988 http://mlb-d1-p.mlstatic.com/driver-motor-de-passo-a4988-stepstick-pololu-reprap-ramps-637001-MLB20252170560_022015-O.webp?square=false to run a NEMA 16 motor (4 wires bipolar).

I did all connections exactly like this diagram http://howtomechatronics.com/wp-content/uploads/2015/08/A4988-Wiring-Diagram.png?e739c9

The problem is this: I see some codes saying that sending a LOW (to the step pin) -> wait a few milliseconds -> sending a HIGH (to the step pin) will make it walk one step. But for some reason in my case it's completely different.

In my case when I do this once (yes, once):

      digitalWrite(step_pin,HIGH); 
      delayMicroseconds(800); 
      digitalWrite(step_pin,LOW); 
      delayMicroseconds(800);

my motor spins forever in a single direction. If I execute the above code again, my motor stops spinnins. It is not taking steps it's is rotating forever till I execute code above. I am using this code below:

const byte step_pin = 3;
const byte dir_pin = 4;

void setup() {

	pinMode(step_pin,OUTPUT);
    pinMode(dir_pin,OUTPUT);
    
    digitalWrite(step_pin,HIGH);
    digitalWrite(dir_pin,HIGH);

}

void loop() {

    char resultado = "";
    
    if (Serial.available()) {
    
    	resultado = (char)Serial.read();
    
    	if (resultado == "a") {
    
              digitalWrite(step_pin,HIGH); 
              delayMicroseconds(800); 
              digitalWrite(step_pin,LOW); 
              delayMicroseconds(800); 
              
		}
    	
    }

}

What is going on? My motor should only spin a single step every time "a" is sent in the Serial, right? But no, it's spinning forever till next time I press "a" and it stops spinning. But if I hit "a" again my motor starts spinning forever again!

May be you should try

if (resultado == [color=red]'a'[/color]) {

@J-M-L it works with ' or with ". I think the problem I am facing is not related with using ' or ".

Why have you started another thread on this topic?
Cross-posting just wastes everyone's time, and those participating in the new thread don't get to see the earlier answers.

You've been here long enough to know better. :frowning:

Stepper motor spinning forever

You also posted in the original thread a few minutes ago, so now you have two active concurrent threads on this at the same time.

Well the single or double quote is a pb in the code for sure but not your pb... Post a picture of your wiring and exact motor and post links as links we can click too...

Are you sure you identified your 4 wires appropriately? probably your issue

Then it's also a duplicated post - why did you ask that twice?
Ask the moderator to merge threads please