Stepper motor for grove
Revision 2:7b7c58bb9831, committed 2019-01-24
- Comitter:
- math991e
- Date:
- Thu Jan 24 12:55:28 2019 +0000
- Parent:
- 1:a77237007141
- Commit message:
- Comments added
Changed in this revision
steppermotor.cpp | Show annotated file Show diff for this revision Revisions of this file |
steppermotor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/steppermotor.cpp Fri Jan 18 08:07:36 2019 +0000 +++ b/steppermotor.cpp Thu Jan 24 12:55:28 2019 +0000 @@ -1,33 +1,76 @@ #include "steppermotor.h" #include "sMotor.h" +///Sets pins for steppermotor sMotor motor(A0, A1, A2, A3); + +/** +* This is the constructor which sets the step speed and number of steps. +* @author Nikolaj M. & Mathias R. +* @param stepSpeed stepspeed to use for steppermotor +* @param numStep number of steps to step with steppermotor +* @date 24/1/2019 +*/ steppermotor::steppermotor(int stepSpeed, int numStep){ setStepSpeed(stepSpeed); setNumStep(numStep); } +/** +* This method will be used to set the variable step_speed. +* @author Nikolaj M. & Mathias R. +* @param stepSpeed value to be set in step_speed +* @date 24/1/2019 +*/ void steppermotor::setStepSpeed(int stepSpeed){ this->step_speed = stepSpeed; } +/** +* This method will be used to get the variable step_speed. +* @author Nikolaj M. & Mathias R. +* @return step_speed value to caller +* @date 24/1/2019 +*/ int steppermotor::getStepSpeed(){ return this->step_speed; } +/** +* This method will be used to set the variable numstep. +* @author Nikolaj M. & Mathias R. +* @param stepSpeed value to be set in step_speed +* @date 24/1/2019 +*/ void steppermotor::setNumStep(int numStep){ this->numstep = numStep; } - + +/** +* This method will be used to get the variable numstep. +* @author Nikolaj M. & Mathias R. +* @return numstep value to caller +* @date 24/1/2019 +*/ int steppermotor::getNumStep(){ return this->numstep; } +/** +* This method will be used to get call funtion that makes steppermotor spin clockwise in sMotor lib. +* @author Nikolaj M. & Mathias R. +* @date 24/1/2019 +*/ void steppermotor::open(){ motor.step(this->getNumStep(),0,this->getStepSpeed()); } +/** +* This method will be used to get call funtion that makes steppermotor spin anticlockwise in sMotor lib. +* @author Nikolaj M. & Mathias R. +* @date 24/1/2019 +*/ void steppermotor::close(){ motor.step(this->getNumStep(),1,this->getStepSpeed()); } \ No newline at end of file
--- a/steppermotor.h Fri Jan 18 08:07:36 2019 +0000 +++ b/steppermotor.h Thu Jan 24 12:55:28 2019 +0000 @@ -1,4 +1,13 @@ /** +* +* @file steppermotor.h +* @brief make grove steppermotor to turn via analog input. +* +* @author Nikolaj M. & Mathias R. +* +* @date 23/1/2019 +* +*-----EXAMPLE----- *#include "steppermotor.h" *steppermotor gate(2200, 200); * @@ -7,17 +16,20 @@ * gate.open(); * gate.close(); *} +*-----EXAMPLE----- **/ +//PROGRAM: StepperMotor #ifndef STEPPERMOTOR #define STEPPERMOTOR - - +///StepperMotor CLASS class steppermotor{ + ///INITIALIZE VARIABLES USED IN CLASS private: int step_speed; int numstep; + ///FUNCTIONS AND CONSTRUCTOR public: steppermotor(int stepSpeed, int numStep); void setStepSpeed(int stepSpeed);