12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
-
-
- #include <unistd.h>
- #include <signal.h>
- #include <iostream>
- #include "adafruitms1438.h"
-
- using namespace std;
- using namespace upm;
-
- int main(int argc, char **argv)
- {
-
-
-
- upm::AdafruitMS1438 *ms =
- new upm::AdafruitMS1438(ADAFRUITMS1438_I2C_BUS,
- ADAFRUITMS1438_DEFAULT_I2C_ADDR);
-
-
-
-
-
-
- ms->disableStepper(AdafruitMS1438::STEPMOTOR_M12);
-
-
- ms->stepConfig(AdafruitMS1438::STEPMOTOR_M12, 200);
-
-
- ms->setStepperSpeed(AdafruitMS1438::STEPMOTOR_M12, 10);
- ms->setStepperDirection(AdafruitMS1438::STEPMOTOR_M12,
- AdafruitMS1438::DIR_CW);
-
-
- cout << "Enabling..." << endl;
- ms->enableStepper(AdafruitMS1438::STEPMOTOR_M12);
-
- cout << "Rotating 1 full revolution at 10 RPM speed." << endl;
- ms->stepperSteps(AdafruitMS1438::STEPMOTOR_M12, 200);
-
- cout << "Sleeping for 2 seconds..." << endl;
- sleep(2);
- cout << "Rotating 1/2 revolution in opposite direction at 10 RPM speed."
- << endl;
-
- ms->setStepperDirection(AdafruitMS1438::STEPMOTOR_M12,
- AdafruitMS1438::DIR_CCW);
- ms->stepperSteps(AdafruitMS1438::STEPMOTOR_M12, 100);
-
- cout << "Disabling..." << endl;
- ms->disableStepper(AdafruitMS1438::STEPMOTOR_M12);
-
- cout << "Exiting" << endl;
-
-
-
- delete ms;
- return 0;
- }
|