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.
Motor/Motor.cpp@0:db8d4af513c0, 2020-01-20 (annotated)
- Committer:
- M_souta
- Date:
- Mon Jan 20 08:46:24 2020 +0000
- Revision:
- 0:db8d4af513c0
- Child:
- 1:5b0303768126
jjjjjj
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| M_souta | 0:db8d4af513c0 | 1 | #include "Motor.h" |
| M_souta | 0:db8d4af513c0 | 2 | |
| M_souta | 0:db8d4af513c0 | 3 | #include "mbed.h" |
| M_souta | 0:db8d4af513c0 | 4 | |
| M_souta | 0:db8d4af513c0 | 5 | MOTOR::MOTOR(PinName D1, PinName D2, PinName pwm) |
| M_souta | 0:db8d4af513c0 | 6 | :D1_(D1), D2_(D2), pwm_(pwm) |
| M_souta | 0:db8d4af513c0 | 7 | { |
| M_souta | 0:db8d4af513c0 | 8 | D1_.write(0); |
| M_souta | 0:db8d4af513c0 | 9 | D2_.write(0); |
| M_souta | 0:db8d4af513c0 | 10 | pwm_.write(0); |
| M_souta | 0:db8d4af513c0 | 11 | } |
| M_souta | 0:db8d4af513c0 | 12 | |
| M_souta | 0:db8d4af513c0 | 13 | void MOTOR::Dir(dire mode, uint8_t pwm) |
| M_souta | 0:db8d4af513c0 | 14 | { |
| M_souta | 0:db8d4af513c0 | 15 | D1_.write((char)mode & 0x01); |
| M_souta | 0:db8d4af513c0 | 16 | D1_.write((char)mode & 0x02); |
| M_souta | 0:db8d4af513c0 | 17 | pwm_.write((float)(pwm / 100.0)); |
| M_souta | 0:db8d4af513c0 | 18 | } |
| M_souta | 0:db8d4af513c0 | 19 | |
| M_souta | 0:db8d4af513c0 | 20 | void MOTOR::Dir(dire mode) |
| M_souta | 0:db8d4af513c0 | 21 | { |
| M_souta | 0:db8d4af513c0 | 22 | D1_.write((char)mode & 0x01); |
| M_souta | 0:db8d4af513c0 | 23 | D1_.write((char)mode & 0x02); |
| M_souta | 0:db8d4af513c0 | 24 | } |
| M_souta | 0:db8d4af513c0 | 25 | |
| M_souta | 0:db8d4af513c0 | 26 | void MOTOR::PWM(uint8_t pwm) |
| M_souta | 0:db8d4af513c0 | 27 | { |
| M_souta | 0:db8d4af513c0 | 28 | pwm_.write((float)(pwm / 100.0)); |
| M_souta | 0:db8d4af513c0 | 29 | } |