//---------------------------------------------------------------------- // https://github.com/clearwater/SwitecX25 // // This is an example of using the SwitchX25 library. // It zero's the motor, sets the position to mid-range // and waits for serial input to indicate new motor positions. // // Open the serial monitor and try entering values // between 0 and 944. // // Note that the maximum speed of the motor will be determined // by how frequently you call update(). If you put a big slow // serial.println() call in the loop below, the motor will move // very slowly! //---------------------------------------------------------------------- #include // standard X25.168 range 315 degrees at 1/3 degree steps #define STEPS (315*3) // For motors connected to digital pins 4,5,6,7 SwitecX25 motor1(STEPS,4,5,6,7); void setup(void) { // run the motor against the stops motor1.zero(); // start moving towards the center of the range motor1.setPosition(STEPS/2); } uint64_t start; void loop(void) { start = millis(); motor1.setPosition(0); while (millis() - start < 500) { motor1.update(); } start = millis(); motor1.setPosition(944); while (millis() - start < 500) { motor1.update(); } }