
This is the first version of this code, pre threading
STEPPER_MOTOR.hpp@1:bc8670cca9f1, 2019-02-05 (annotated)
- Committer:
- JDickson
- Date:
- Tue Feb 05 14:41:13 2019 +0000
- Revision:
- 1:bc8670cca9f1
- Parent:
- 0:fa46f9c77bd5
Version 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JDickson | 0:fa46f9c77bd5 | 1 | /* |
JDickson | 0:fa46f9c77bd5 | 2 | This is the stepper motor class and is used to control all of the motors individually |
JDickson | 0:fa46f9c77bd5 | 3 | */ |
JDickson | 0:fa46f9c77bd5 | 4 | |
JDickson | 0:fa46f9c77bd5 | 5 | #ifndef STEPPER_MOTOR_HPP//Header Guards Prevents Multiple includes |
JDickson | 0:fa46f9c77bd5 | 6 | #define STEPPER_MOTOR_HPP |
JDickson | 0:fa46f9c77bd5 | 7 | |
JDickson | 0:fa46f9c77bd5 | 8 | //Libraries and header includes |
JDickson | 0:fa46f9c77bd5 | 9 | #include "mbed.h" |
JDickson | 0:fa46f9c77bd5 | 10 | #include "rtos.h" |
JDickson | 0:fa46f9c77bd5 | 11 | class STEPPER_MOTOR //This creates a class called Led |
JDickson | 0:fa46f9c77bd5 | 12 | { |
JDickson | 0:fa46f9c77bd5 | 13 | public: |
JDickson | 0:fa46f9c77bd5 | 14 | |
JDickson | 0:fa46f9c77bd5 | 15 | STEPPER_MOTOR(PinName N1, PinName N2, PinName N3, PinName N4); //Constructor |
JDickson | 0:fa46f9c77bd5 | 16 | ~STEPPER_MOTOR(); //Destructor |
JDickson | 0:fa46f9c77bd5 | 17 | void Permanent_Rotate(); |
JDickson | 0:fa46f9c77bd5 | 18 | void Permanent_Rotate_clock_wise(); |
JDickson | 0:fa46f9c77bd5 | 19 | void Permanent_Rotate_anti_clock_wise(); |
JDickson | 0:fa46f9c77bd5 | 20 | void Rotate_90(); |
JDickson | 0:fa46f9c77bd5 | 21 | void Rotate_Steps(int Steps); |
JDickson | 0:fa46f9c77bd5 | 22 | private: |
JDickson | 0:fa46f9c77bd5 | 23 | //Private member variables to prevent them being accessed externally |
JDickson | 0:fa46f9c77bd5 | 24 | //Data Pins |
JDickson | 0:fa46f9c77bd5 | 25 | bool _dir; |
JDickson | 0:fa46f9c77bd5 | 26 | int _step; |
JDickson | 0:fa46f9c77bd5 | 27 | int _Number_of_steps; |
JDickson | 0:fa46f9c77bd5 | 28 | DigitalOut pin1; //Pin 1 |
JDickson | 0:fa46f9c77bd5 | 29 | DigitalOut pin2; //Pin 2 |
JDickson | 0:fa46f9c77bd5 | 30 | DigitalOut pin3; //Pin 3 |
JDickson | 0:fa46f9c77bd5 | 31 | DigitalOut pin4; //Pin 4 |
JDickson | 0:fa46f9c77bd5 | 32 | |
JDickson | 0:fa46f9c77bd5 | 33 | }; |
JDickson | 0:fa46f9c77bd5 | 34 | #endif//STEPPER_MOTOR_HPP |