Page 243 - 최강 아두이노 퍼스트 참고서
P. 243
{
stepper(1);
time=time+micros()-last_time;
last_time=micros();
steps_left--;
}
} // while
Serial.println(time);
Serial.println("Wait...!");
delay(2000);
Direction=!Direction; // 諛섏쟾.
steps_left=4095;
}
void stepper(int xw)
{
for (int x=0;x<xw;x++)
{
switch(Steps)
{
case 0:
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
break;
case 1:
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, HIGH);
break;
case 2:
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
break;
case 3:
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
break;
case 4:
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
break;
243