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.
Dependencies: HCSR04 mbed-rtos mbed
Fork of MotorShield_futura by
Revision 0:637e2ec8d164, committed 2017-05-22
- Comitter:
- Wonderjack996
- Date:
- Mon May 22 08:42:32 2017 +0000
- Child:
- 1:009a67d6875f
- Commit message:
- programma per commando motori
;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon May 22 08:42:32 2017 +0000
@@ -0,0 +1,71 @@
+#include "mbed.h"
+
+#define PWMB PC_7 //D9
+#define DIRB D8 //D8
+
+#define PWMA PB_4 //D5
+#define DIRA D4 //D4
+
+PwmOut motorBpower(PWMB);
+DigitalOut motorBdirection(DIRB);
+
+PwmOut motorApower(PWMA);
+DigitalOut motorAdirection(DIRA);
+
+void avanti();
+void indietro();
+void destra();
+void sinistra();
+void fermo();
+
+int main() {
+
+ motorBpower.period_ms(10);
+ motorApower.period_ms(10);
+
+ wait(2);
+
+ avanti();
+ wait(2);
+ fermo();
+
+ while(true);
+}
+
+void avanti()
+{
+ motorBdirection = 1;
+ motorAdirection = 0;
+ motorBpower.pulsewidth(0.01); // 100%
+ motorApower.pulsewidth(0.01); // 100%
+}
+
+void indietro()
+{
+ motorBdirection = 0;
+ motorAdirection = 1;
+ motorBpower.pulsewidth(0.01); // 100%
+ motorApower.pulsewidth(0.01); // 100%
+}
+
+void destra()
+{
+ motorBdirection = 0;
+ motorAdirection = 0;
+ motorBpower.pulsewidth(0.01); // 100%
+ motorApower.pulsewidth(0.007); // 70%
+}
+
+void sinistra()
+{
+ motorBdirection = 1;
+ motorAdirection = 1;
+ motorBpower.pulsewidth(0.007); // 100%
+ motorApower.pulsewidth(0.01); // 100%
+}
+
+void fermo()
+{
+ motorBpower.pulsewidth(0); // fermo
+ motorApower.pulsewidth(0); // fermo
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 22 08:42:32 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/093f2bd7b9eb \ No newline at end of file
