# HELP for Nema 17 stepper motor arduino Code

Hello
First of all i must say that i am really happy to be a member of this platform.Let me introduce myself.
I study mechanical engineering in a technical university and i am interested in electronics.
For a competetion in Holland , we design a wind powered car. I use nema 23 stepper motor to give direction with its special driver. I will use a anemometer that has analog outputs and according to outputs i will give direction to my step motor.
I have code that belongs to me;

int kayit[2];

void setup() {
// put your setup code here, to run once:
pinMode(8, OUTPUT); //direction pin
pinMode(9, OUTPUT); //step pin
digitalWrite(8, HIGH);
digitalWrite(9, LOW);

}

void loop() {
int deger;
int deger2;
int fark;
// put your main code here, to run repeatedly:
int i;

kayit[0]=deger;

delay(3000);
kayit[1]=deger2;

fark=(kayit[1]-kayit[0]);
if (fark==0)
{
digitalWrite(9,LOW);
}
else if (fark>0)
{
digitalWrite(8,HIGH);
for (i=0;i<=fark;i++)
{
digitalWrite(9,HIGH);
delayMicroseconds(500);
digitalWrite(9, LOW);
delayMicroseconds(500);
}
}
else if (fark<0)
{
fark=fark*(-1);
digitalWrite(8,LOW);
for(i=0;i<=fark;i++)
{
digitalWrite(9,HIGH);
delayMicroseconds(500);
digitalWrite(9, LOW);
delayMicroseconds(500);
}

}

delay(100);
}

For this code , if i use potentiometer for trying what happens, it is not good outputs to run my motor.
Can you guys help me ?

I study mechanical engineering in a technical university

Then you should be aware of what the various standards mean. What does NEMA 17 cover? How is THAT information relevant to us?

with its special driver.

What driver is that?

For this code , if i use potentiometer for trying what happens, it is not good outputs to run my motor.

How do you know? You are not printing the value read from the pot. You are not printing the value that that value is mapped to. You are, instead, assuming all kinds of things that may not be true. That will get you nowhere as an engineer.

Please modify your post and use the code button </> `so your code looks like this` and is easy to copy to a text editor. See How to use the Forum

Please let us know whether it is a Nema 17 (in your title) or Nema 23 (in your description).

More practically, post links to the datasheets for the stepper motor and the stepper motor driver.

You also need to tell us what your program actually does and what you want it to do.

Sorry for my topic, I am new in this forum. Now let me introduce myself again. I use Nema 17 stepper motor and its driver ZM-2H042. Now I have a anemometer that send analog values ( insists a potentiometer inside) I want to read these values from anemometer ( wind direction sensor) and according to these values i want to change my motor location. Motor is connected to a gear that rotates a nozzle. If anemometer towards to north , my nozzle also will towards to north.