Wiper movement with stepper motor

Hi folks,

I have a problem with writing a code to run my stepper motor which is a 7.5 degree step , I want it to move 110 degrees back and forth in a loop like the way windshield wiper is working.

const int stepPin = 3;
const int dirPin = 4;

void setup() {
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
}

void loop() {
digitalWrite(dirPin,HIGH);
for(int x =0; x <= 15; x++)
{
for(int y =0; y <= 4; y++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
digitalWrite(dirPin,LOW);
for(int x =0; x <= 15; x++)
{
for(int y =0; y <= 4; y++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
}

Can you please help me to fix it?

Can you please help me to fix it?

Without knowing how it is broken? Not likely.

Since you do not use the values of either loop index in the body of the for statements, there is no point in having nested for loops.

babakkhoda: I have a problem with writing a code to run my stepper motor which is a 7.5 degree step , I want it to move 110 degrees back and forth in a loop like the way windshield wiper is working.

110 degrees is not a multiple of 7.5 degrees so unless you are willing to compromise and accept 112.5 degrees (say) then you have a fundamental problem.

PaulS:
Without knowing how it is broken? Not likely.

Since you do not use the values of either loop index in the body of the for statements, there is no point in having nested for loops.

it is working one way, like 110 degrees in clockwise is working but it will stop after that instead of CCW!

What is between the Arduino and the stepper motor?