![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
FINAL PROJECT isn't it
Fork of ELEC351 by
STEPPER_MOTOR.cpp
- Committer:
- thomasmorris
- Date:
- 2018-08-15
- Revision:
- 57:aba1296e51b1
- Parent:
- 53:71f59e195f06
File content as of revision 57:aba1296e51b1:
#include "mbed.h" //Include the mbed libraries #include "STEPPER_MOTOR.hpp" //Include the header file, this acts like a series of forward declarations #include "SERIAL_COMMANDS.hpp" //Constructor STEPPER_MOTOR::STEPPER_MOTOR(PinName STEP, PinName DIRECTION) : _STEP(STEP), _DIRECTION(DIRECTION) //Constructor { } STEPPER_MOTOR::~STEPPER_MOTOR(){} //Destructor void STEPPER_MOTOR::Rotate_Steps(int Steps, int Direction)//Test this with the larger delay to see if that will increase the performance { _DIRECTION = Direction; for(int x =0 ; x < Steps; x++) { _STEP = 1; //wait_us(500); wait_ms(5); //Thread::wait(1);//wait 1 ms _STEP = 0; wait_ms(5); //wait_us(500); //Thread::wait(1);//wait 1ms } steps = 0; } void STEPPER_MOTOR::Permanent_Rotate_clock_wise() { _DIRECTION = 1; for(int x = 0; x< 200; x++) { _STEP = 1; wait_us(500); //Thread::wait(1);//wait 1 ms _STEP = 0; wait_us(500); //Thread::wait(1);//wait 1ms } } void STEPPER_MOTOR::Permanent_Rotate_anti_clock_wise() { _DIRECTION = 0;//For anti clockwise rotation for(int x = 0; x< 200; x++) { _STEP = 1; wait_us(500); //Thread::wait(1);//wait 1 ms _STEP = 0; wait_us(500); //Thread::wait(1);//wait 1ms } }