https://youtu.be/19aZK3uc-II
// Stepper Travel Variables
long TravelX; // Used to store the X value entered in the Serial Monitor시리얼 모니터에 입력 된 X 값을 저장하는데 사용됩니다
int move_finished=1; // Used to check if move is completed확인하는 데 사용 하면 이동이 됩니다 완료
long initial_homing=-1; // Used to Home Stepper at startup시작시 홈 스테퍼에 사용
void setup() {
Serial.begin(9600); // Start the Serial monitor with speed of 9600 Bauds직렬 모니터 와 속도 9600 Bauds
pinMode(home_switch, INPUT_PULLUP);
delay(5); // Wait for EasyDriver wake up
// Set Max Speed and Acceleration of each Steppers at startup for homing stepperX에 대한 시작시 각 스테퍼의 최대 속도 및 가속을 설정 합니다.
stepperX.setMaxSpeed(100.0); // Set Max Speed of Stepper (Slower to get better accuracy)Stepper의 최대 속도를 설정합니다 (더 나은 정확도를 얻으려면 느리게)
stepperX.setAcceleration(100.0); // Set Acceleration of Stepper
// Start Homing procedure of Stepper Motor at startup시작시 Stepper Motor의 Homing 절차 시작
Serial.print("Stepper is Homing . . . . . . . . . . . ");
while (digitalRead(home_switch)) { // Make the Stepper move CCW until the switch is activated 스위치가 될 때까지 스테퍼 이동 CCW를 확인 한다 활성화
stepperX.moveTo(initial_homing); // Set the position to move to
initial_homing--; // Decrease by 1 for next move if needed필요한 경우 다음 이동을 위해 1 씩 감소
stepperX.run(); // Start moving the stepper
delay(5);
}
stepperX.setCurrentPosition(0); // Set the current position as zero for now설정된 현재의 위치 로 제로
stepperX.setMaxSpeed(1000.0); // Set Max Speed of Stepper (Slower to get better accuracy)Stepper의 최대 속도를 설정
stepperX.setAcceleration(1000.0); // Set Acceleration of Stepper스테퍼 가속도 설정
initial_homing=1;
while (!digitalRead(home_switch)) { // Make the Stepper move CW until the switch is deactivated위치가 될 때까지 스테퍼 이동 CW를 확인 한다 비활성화
stepperX.moveTo(initial_homing);
stepperX.run();
initial_homing--;
delay(5);
}
stepperX.setCurrentPosition(0);
Serial.println("Homing Completed");
Serial.println("");
stepperX.setMaxSpeed(1000.0); // Set Max Speed of Stepper (Faster for regular movements)스테퍼 세트 최대 속도 (빠른 에 대한 정기적 인 운동)
stepperX.setAcceleration(1000.0); // Set Acceleration of Stepper스테퍼의 가속도 설정
// Print out Instructions on the Serial Monitor at Start
Serial.println("Enter Travel distance (Positive for CW / Negative for CCW and Zero for back to Home): ");
}
void loop() {
while (Serial.available()>0) { // Check if values are available in the Serial Buffer
move_finished=0; // Set variable for checking move of the StepperStepper의 움직임 을 확인 하기위한 변수 설정
TravelX= Serial.parseInt(); // Put numeric value from buffer in TravelX variable
if (TravelX < 0 || TravelX > 5000) { // Make sure the position entered is not beyond the HOME or MAX position반드시 입력 위치가 확인 입니다 하지 홈 넘어 또는 MAX 위치
Serial.println("");
Serial.println("Please enter a value greater than zero and smaller or equal to 1350.....");//("0보다 크고 1350 .....보다 작거나 같은 값을 입력하십시오." ) ;
Serial.println("");
} else {
Serial.print("Moving stepper into position: ");
Serial.println(TravelX);
stepperX.moveTo(TravelX); // Set new moveto position of Stepper// Stepper의 새로운 이동 위치 설정
delay(1000); // Wait 1 seconds before moving the Stepper스테퍼를 움직이기 전에 1 초 동안 기다 립니다.
}
}
if (TravelX >= 0 && TravelX <= 5000) {
// Check if the Stepper has reached desired position 체크 경우 스텝퍼가 원하는 위치에 도달 한
//경우
if ((stepperX.distanceToGo() != 0)) {
stepperX.run(); // Move Stepper into position
}
// If move is completed display message on Serial Monitor이동 이 완료되면 Serial Monitor에 메시지를 표시
if ((move_finished == 0) && (stepperX.distanceToGo() == 0)) {
Serial.println("COMPLETED!");
Serial.println("");
Serial.println("Enter Travel distance (Positive for CW / Negative for CCW and Zero for back to Home): ");//"이동 거리 입력 (CW의 경우 양수 / CCW의 경우 음수, 홈으로 돌아가는 경우 0)
move_finished=1; // Reset move variable
}
}
}