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.
Dependents: Coba_Motor_Driver_V2
Diff: motor.cpp
- Revision:
- 0:de471bead4f2
- Child:
- 1:98a8282033ab
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/motor.cpp Wed Oct 03 11:01:42 2018 +0000
@@ -0,0 +1,24 @@
+#include "motor.h"
+
+
+
+motor :: motor ( PinName dright , PinName dleft, PinName pwmpin) : _dright(dright) , _dleft(dleft), _pwmpin(pwmpin)
+{
+ _pwmpin.period_us(50);
+}
+
+void motor::setpwm(float inputpwm )
+{
+ if ( inputpwm >= 0 )
+ {
+ _dright = 1;
+ _dleft = 0;
+ _pwmpin.write(inputpwm);
+ }
+ else
+ {
+ _dright = 0;
+ _dleft = 1;
+ _pwmpin.write(-1*inputpwm);
+ }
+}
\ No newline at end of file