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.
Diff: Motor/Motor.cpp
- Revision:
- 1:5b0303768126
- Parent:
- 0:db8d4af513c0
- Child:
- 2:32d2cd7d744b
diff -r db8d4af513c0 -r 5b0303768126 Motor/Motor.cpp
--- a/Motor/Motor.cpp Mon Jan 20 08:46:24 2020 +0000
+++ b/Motor/Motor.cpp Tue Jan 21 11:10:33 2020 +0000
@@ -7,23 +7,24 @@
{
D1_.write(0);
D2_.write(0);
+ pwm_.period_us(50); // 20kHz
pwm_.write(0);
}
void MOTOR::Dir(dire mode, uint8_t pwm)
{
D1_.write((char)mode & 0x01);
- D1_.write((char)mode & 0x02);
- pwm_.write((float)(pwm / 100.0));
+ D2_.write((char)mode & 0x02);
+ pwm_.write((float)(pwm / 255.0));
}
void MOTOR::Dir(dire mode)
{
D1_.write((char)mode & 0x01);
- D1_.write((char)mode & 0x02);
+ D2_.write((char)mode & 0x02);
}
void MOTOR::PWM(uint8_t pwm)
{
- pwm_.write((float)(pwm / 100.0));
+ pwm_.write((float)(pwm / 255.0));
}
\ No newline at end of file