Skip to content

Instantly share code, notes, and snippets.

@pratimugale
Last active July 17, 2019 17:16
Show Gist options
  • Save pratimugale/76e6b637896ac96093ae396efd5f020e to your computer and use it in GitHub Desktop.
Save pratimugale/76e6b637896ac96093ae396efd5f020e to your computer and use it in GitHub Desktop.
#include "driver_lib.h"
#include <iostream>
using namespace std;
int main(){
Driver& d = Driver::get();
d.wake();
d.activateMotor(360.0, 60.0, FULL, ANTICLOCKWISE); // 360 degrees at 60 RPM in full step mode in anticlockwise direction
d.activateMotor(360.0, 60.0, HALF, ANTICLOCKWISE);
d.activateMotor(360.0, 60.0, QUARTER, ANTICLOCKWISE);
d.activateMotor(360.0, 60.0, EIGHT, ANTICLOCKWISE);
d.activateMotor(360.0, 60.0, EIGHT);
d.activateMotor(360.0, 60.0, QUARTER);
d.activateMotor(360.0, 60.0, HALF);
d.activateMotor(360.0, 60.0, FULL);
// To demonstrate sleeping - The motor should be able to freely rotate for 10 seconds
d.sleep();
usleep(5000000);
d.wake();
d.activateMotor(180.0, 150.0, EIGHT, ANTICLOCKWISE);
d.activateMotor(180.0, 150.0, EIGHT, CLOCKWISE);
d.activateMotor(180.0, 150.0, EIGHT, ANTICLOCKWISE);
d.activateMotor(180.0, 150.0, EIGHT, CLOCKWISE);
d.activateMotor(180.0, 150.0, EIGHT, ANTICLOCKWISE);
d.activateMotor(180.0, 150.0, EIGHT, CLOCKWISE);
d.activateMotor(180.0, 150.0, EIGHT, ANTICLOCKWISE);
d.activateMotor(180.0, 150.0, EIGHT, CLOCKWISE);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment