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.
Revision 0:86d90c65f83b, committed 2019-09-16
- Comitter:
- alienbernamaihsan
- Date:
- Mon Sep 16 10:06:48 2019 +0000
- Commit message:
- PRAWIRA; ;
Changed in this revision
| Motor.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Motor.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.cpp Mon Sep 16 10:06:48 2019 +0000
@@ -0,0 +1,17 @@
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.h Mon Sep 16 10:06:48 2019 +0000
@@ -0,0 +1,18 @@
+#ifndef MOTOR_H
+#define MOTOR_H
+
+#include "mbed.h"
+
+class Motor {
+
+public :
+ Motor(PinName dright , PinName dleft, PinName pwmpin);
+ void setpwm(float inputpwm);
+
+private :
+ PwmOut pwmpin_;
+ DigitalOut dright_;
+ DigitalOut dleft_;
+};
+
+#endif
\ No newline at end of file