const int DIR = 8 ; // board driver
const int STEP = 9 ; // board driver
const int step_per_attc= 125;
void setup() {
Serial.begin(115200);
pinMode(DIR, OUTPUT);
pinMode(STEP, OUTPUT);
}
void loop() {
digitalWrite(DIR, HIGH);
Serial.println("ATTC Motor Clockwise");// ตามเข็มนาฬิกา
for (int i=0; i < step_per_attc ;i++ ) {
digitalWrite(STEP, HIGH);
delayMicroseconds(10000);
digitalWrite(STEP, LOW);
delayMicroseconds(10000);
}
delay(1000);
digitalWrite(DIR, LOW);
Serial.println("ATTC Motor AntiClockwise");// ทวนเข็มนาฬิกา
for (int i=0; i < step_per_attc ;i++ ) {
digitalWrite(STEP, HIGH);
delayMicroseconds(10000);
digitalWrite(STEP, LOW);
delayMicroseconds(10000);
}
delay(1000);
}