Steven Swenson / Motor

Dependents:   tuner

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Motor.cpp Source File

Motor.cpp

00001 #include "Motor.h"
00002 
00003 Motor::Motor(PinName enable,PinName direction,PinName step) : _enable(enable), _direction(direction), _step(step) {
00004 _enable=1;
00005 }
00006 
00007 Motor::~Motor() {
00008 }
00009 
00010 void Motor::motor_turn(int direction, int steps) {
00011     _enable=0;
00012     float freq=600;//frequency of PWM signal to drive stepper motor
00013     _step.period(1/freq);
00014     _step.write(.5);
00015     _direction=direction;
00016     wait(steps*(1/freq));
00017     _step.write(0);
00018     _enable=1;
00019 }