software to control a DC motor, preferably interfacing with a motor driver.
DCMotor.h@2:46bca6d9dbda, 2011-07-15 (annotated)
- Committer:
- kaushalpkk
- Date:
- Fri Jul 15 17:58:29 2011 +0000
- Revision:
- 2:46bca6d9dbda
- Parent:
- 1:88772267f757
- Child:
- 3:a0dc016b7cbb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kaushalpkk | 0:c92be90656b7 | 1 | #ifndef MBED_DCMOTOR_H |
kaushalpkk | 0:c92be90656b7 | 2 | #define MBED_DCMOTOR_H |
kaushalpkk | 0:c92be90656b7 | 3 | |
kaushalpkk | 0:c92be90656b7 | 4 | #include "mbed.h" |
kaushalpkk | 0:c92be90656b7 | 5 | |
kaushalpkk | 0:c92be90656b7 | 6 | class DCMotor { |
kaushalpkk | 0:c92be90656b7 | 7 | |
kaushalpkk | 0:c92be90656b7 | 8 | public: |
kaushalpkk | 1:88772267f757 | 9 | /** create a DCMotor object connected to the pins with speed control |
kaushalpkk | 2:46bca6d9dbda | 10 | * @param PWMPin PWM pin to control speed of motor |
kaushalpkk | 2:46bca6d9dbda | 11 | * @param PinA Digital output pin to connect to motor |
kaushalpkk | 2:46bca6d9dbda | 12 | * @param PinB Digital output pin to connect to motor |
kaushalpkk | 1:88772267f757 | 13 | */ |
kaushalpkk | 0:c92be90656b7 | 14 | DCMotor(PinName PWMPin, PinName PinA, PinName PinB); |
kaushalpkk | 1:88772267f757 | 15 | |
kaushalpkk | 1:88772267f757 | 16 | /** drive Motor input range (-100 to 100). |
kaushalpkk | 2:46bca6d9dbda | 17 | * @param perCent PWM pin to control speed of motor |
kaushalpkk | 1:88772267f757 | 18 | */ |
kaushalpkk | 0:c92be90656b7 | 19 | void driveIt(float); |
kaushalpkk | 1:88772267f757 | 20 | |
kaushalpkk | 0:c92be90656b7 | 21 | protected: |
kaushalpkk | 0:c92be90656b7 | 22 | PwmOut _PWMPin; |
kaushalpkk | 0:c92be90656b7 | 23 | DigitalOut _PinA; |
kaushalpkk | 0:c92be90656b7 | 24 | DigitalOut _PinB; |
kaushalpkk | 0:c92be90656b7 | 25 | }; |
kaushalpkk | 0:c92be90656b7 | 26 | |
kaushalpkk | 0:c92be90656b7 | 27 | #endif |