![](/media/cache/profiles/bcbc28b41f550d272eb2f1d343011760.jpg.50x50_q85.jpg)
motor i senzor
Dependencies: TextLCD mbed PinDetect
MotorDrivers/Motor.h@3:bebfc64cefe4, 2013-11-09 (annotated)
- Committer:
- mdraganic
- Date:
- Sat Nov 09 13:44:18 2013 +0000
- Revision:
- 3:bebfc64cefe4
- Parent:
- 1:3500bf8487d0
- Child:
- 4:03b68322905f
sve skupa i zajedno
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mdraganic | 1:3500bf8487d0 | 1 | #ifndef MOTOR_H |
mdraganic | 1:3500bf8487d0 | 2 | #define MOTOR_H |
mdraganic | 1:3500bf8487d0 | 3 | |
mdraganic | 1:3500bf8487d0 | 4 | #include "mbed.h" |
mdraganic | 1:3500bf8487d0 | 5 | |
mdraganic | 3:bebfc64cefe4 | 6 | #define motorDriveTime 100 // vrijeme koje se motor kreće, u milisekundama. |
mdraganic | 3:bebfc64cefe4 | 7 | #define motorPwmPeriod 0.010 // PWM period to 10 ms |
mdraganic | 3:bebfc64cefe4 | 8 | #define motorPwmInitDutyCycle 0.5 // PWM initial duty cycle, 50% |
mdraganic | 3:bebfc64cefe4 | 9 | #define motorPwmWaitTime 0.02 // PWM wait time in sec. |
mdraganic | 3:bebfc64cefe4 | 10 | #define motorPwmChangeSpeed 0.2 // PWM value change |
mdraganic | 1:3500bf8487d0 | 11 | |
mdraganic | 1:3500bf8487d0 | 12 | class Motor { |
mdraganic | 1:3500bf8487d0 | 13 | |
mdraganic | 1:3500bf8487d0 | 14 | private: |
mdraganic | 1:3500bf8487d0 | 15 | DigitalOut positiveOut, negativeOut; |
mdraganic | 3:bebfc64cefe4 | 16 | PwmOut pwmOut; |
mdraganic | 1:3500bf8487d0 | 17 | short direction; |
mdraganic | 1:3500bf8487d0 | 18 | void move(); |
mdraganic | 3:bebfc64cefe4 | 19 | bool _isMoving; |
mdraganic | 1:3500bf8487d0 | 20 | |
mdraganic | 1:3500bf8487d0 | 21 | public: |
mdraganic | 3:bebfc64cefe4 | 22 | Motor(PinName, PinName, PinName); |
mdraganic | 1:3500bf8487d0 | 23 | void movePositive(); |
mdraganic | 1:3500bf8487d0 | 24 | void moveNegative(); |
mdraganic | 3:bebfc64cefe4 | 25 | void stop(); |
mdraganic | 3:bebfc64cefe4 | 26 | bool isMoving(); |
mdraganic | 1:3500bf8487d0 | 27 | |
mdraganic | 1:3500bf8487d0 | 28 | }; |
mdraganic | 1:3500bf8487d0 | 29 | |
mdraganic | 1:3500bf8487d0 | 30 | #endif |