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 PulseMotor by
Revision 1:c533a17dccc0, committed 2015-01-10
- Comitter:
- Honmaka
- Date:
- Sat Jan 10 06:25:14 2015 +0000
- Parent:
- 0:27fe3b05f1fc
- Commit message:
- PulseMotor sample program with switch
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 27fe3b05f1fc -r c533a17dccc0 main.cpp
--- a/main.cpp Sun Jan 04 07:55:14 2015 +0000
+++ b/main.cpp Sat Jan 10 06:25:14 2015 +0000
@@ -1,10 +1,24 @@
#include "mbed.h"
PwmOut PulseMotor(p21);
+DigitalIn MotorSpeedSw(p5);
+DigitalIn MotorDirectionSw(p6);
+DigitalOut MotorDirectionOut(p7);
int main() {
- PulseMotor.period_us(83140);
- PulseMotor.pulsewidth_us(83140/2);
+ MotorSpeedSw.mode(PullUp);
+ MotorDirectionSw.mode(PullUp);
+ //Dorection
+ MotorDirectionOut = MotorDirectionSw;
+ //Speed
+ if (MotorSpeedSw == 1) { //Normal Speed
+ PulseMotor.period_us(83140);
+ PulseMotor.pulsewidth_us(83140/2);
+ }
+ else { //Half Speed
+ PulseMotor.period_us(83140*2);
+ PulseMotor.pulsewidth_us((83140*2)/2);
+ }
while(1) {
}
}
