# Two stepper motor rotate with sine and cosine wave

I am new to robotics, and I’m unsure if this is a really dumb question or not. I have two micro stepper drivers and two stepper motors, and my objective is to rotate the two stepper motors using a sine wave for one motor and a cosine wave for the other. Currently, with the current code utilizing 800 microsteps, the two stepper motors rotate at the same speed. How can I achieve the rotation of the two motors with sine and cosine waves?

``````int x;

void setup()
{
pinMode(9, OUTPUT); // set Pin9 as PUL for motor 1
pinMode(8, OUTPUT); // set Pin8 as DIR for motor 1
pinMode(3, OUTPUT); // set Pin3 as PUL for motor 2
pinMode(2, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
digitalWrite(2, HIGH);

for (x = 0; x < 800; x++)
{
digitalWrite(9, HIGH);
delayMicroseconds(1000);
digitalWrite(9, LOW);
delayMicroseconds(1000);

digitalWrite(3, HIGH);
delayMicroseconds(1000);
digitalWrite(3, LOW);
delayMicroseconds(1000);

}

delayMicroseconds(1000);

}
``````

Hello.

Can you explain more specifically what you are trying to do and what hardware you are using?

- Patrick