A program to automatically tune a guitar. Written by Justin Reidhead and Steven Swenson
Dependencies: FFT FrequencyFinder Motor NewTextLCD PinDetect mbed strings
Motor/Motor.cpp@5:c0fd99f07536, 2012-04-17 (annotated)
- Committer:
- melangeaddict
- Date:
- Tue Apr 17 19:46:33 2012 +0000
- Revision:
- 5:c0fd99f07536
- Parent:
- 2:9c0a83c5ded5
- Child:
- 8:651fbf5ae98a
It's a trap!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
melangeaddict | 2:9c0a83c5ded5 | 1 | #include "Motor.h" |
melangeaddict | 2:9c0a83c5ded5 | 2 | |
melangeaddict | 2:9c0a83c5ded5 | 3 | Motor::Motor(PinName enable,PinName direction,PinName step) : _enable(enable), _direction(direction), _step(step) { |
melangeaddict | 5:c0fd99f07536 | 4 | _enable=1; |
melangeaddict | 2:9c0a83c5ded5 | 5 | } |
melangeaddict | 2:9c0a83c5ded5 | 6 | |
melangeaddict | 2:9c0a83c5ded5 | 7 | Motor::~Motor() { |
melangeaddict | 2:9c0a83c5ded5 | 8 | } |
melangeaddict | 2:9c0a83c5ded5 | 9 | |
melangeaddict | 2:9c0a83c5ded5 | 10 | void Motor::motor_turn(int direction, int steps) { |
melangeaddict | 2:9c0a83c5ded5 | 11 | _enable=0; |
melangeaddict | 5:c0fd99f07536 | 12 | float freq=100;//frequency of PWM signal to drive stepper motor |
melangeaddict | 2:9c0a83c5ded5 | 13 | _step.period(1/freq); |
melangeaddict | 2:9c0a83c5ded5 | 14 | _step.write(.5); |
melangeaddict | 2:9c0a83c5ded5 | 15 | _direction=direction; |
melangeaddict | 2:9c0a83c5ded5 | 16 | wait(steps*(1/freq)); |
melangeaddict | 2:9c0a83c5ded5 | 17 | _step.write(0); |
melangeaddict | 2:9c0a83c5ded5 | 18 | _enable=1; |
melangeaddict | 2:9c0a83c5ded5 | 19 | } |