Reed switch and stepper motor

I have pasted my code below .

Using Tools + Auto Format would be a really good idea.

I like each { on a new line, too.

Consistent use of curly braces after if statements would be good, too.

    if(Stepper1.run() ==0)
    digitalWrite(4,HIGH);

You may decide that there are two things that need to be done when some condition is met. Adding the curly braces later is much more effort, in my opinion, than adding them in the first place.

Function names that reflect what they do are good.

  spam();

It's not possible to even guess what this function does, in a motor control program. In a e-mail generating application, maybe, but not here.

If you can't decide what the name ought to be, then you haven't thought enough about what the function is going to do.

A judicious amount of white space is good. More is not.

  Stepper1.setMaxSpeed(500);
  Stepper1.setAcceleration(500);
  spam();
 
}

That blank line does NOT improve the readability of the code. Lose it, and the other ones like it.

Just my final 2 cents.