Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Motor2 by
motor.h@0:5cafacc2a607, 2013-07-29 (annotated)
- Committer:
- Reiko
- Date:
- Mon Jul 29 20:25:33 2013 +0000
- Revision:
- 0:5cafacc2a607
- Child:
- 1:c97f8bcd6c0f
Created motor library
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Reiko | 0:5cafacc2a607 | 1 | #ifndef MOTOR_H |
| Reiko | 0:5cafacc2a607 | 2 | #define MOTOR_H |
| Reiko | 0:5cafacc2a607 | 3 | |
| Reiko | 0:5cafacc2a607 | 4 | #include "mbed.h" |
| Reiko | 0:5cafacc2a607 | 5 | |
| Reiko | 0:5cafacc2a607 | 6 | class Motor { |
| Reiko | 0:5cafacc2a607 | 7 | public: |
| Reiko | 0:5cafacc2a607 | 8 | Motor(PinName PWMpin, PinName dir1Pin, PinName dir2Pin); |
| Reiko | 0:5cafacc2a607 | 9 | |
| Reiko | 0:5cafacc2a607 | 10 | void setSpeed(int newSpeed); |
| Reiko | 0:5cafacc2a607 | 11 | int getSpeed(); |
| Reiko | 0:5cafacc2a607 | 12 | |
| Reiko | 0:5cafacc2a607 | 13 | private: |
| Reiko | 0:5cafacc2a607 | 14 | void pid(); |
| Reiko | 0:5cafacc2a607 | 15 | |
| Reiko | 0:5cafacc2a607 | 16 | InterruptIn interruptA; |
| Reiko | 0:5cafacc2a607 | 17 | InterruptIn interruptB; |
| Reiko | 0:5cafacc2a607 | 18 | |
| Reiko | 0:5cafacc2a607 | 19 | volatile int pulses; |
| Reiko | 0:5cafacc2a607 | 20 | |
| Reiko | 0:5cafacc2a607 | 21 | int prevState; |
| Reiko | 0:5cafacc2a607 | 22 | int currState; |
| Reiko | 0:5cafacc2a607 | 23 | }; |
| Reiko | 0:5cafacc2a607 | 24 | |
| Reiko | 0:5cafacc2a607 | 25 | #endif |
