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: mbed
Diff: main.cpp
- Revision:
- 2:5a81778c8f8b
- Parent:
- 0:4860a91fb495
- Child:
- 3:aecdaed3e772
--- a/main.cpp Mon Feb 17 22:16:24 2014 +0000
+++ b/main.cpp Mon Nov 02 14:02:13 2015 +0000
@@ -1,18 +1,37 @@
+/****************************************************
+* FAST PROTOTYPING WITH NUCLEO *
+* Example Code 09: DC motor control *
+* Author: Mauro D'Angelo *
+* Organization: Perlatecnica no-profit organization *
+*****************************************************/
#include "mbed.h"
-PwmOut mypwm(PWM_OUT);
+#define PWMB PA_7
+#define DIRB PA_5
+
+#define PWMA PB_3
+#define DIRA PA_6
+// Instanzia un oggetto di tipo PwmOut e gli da il nome mypwm
+PwmOut mypwm(PWMB);
+// Definisce il pin che indica la direzione
+DigitalOut motordir(DIRB);
+
+// Instanzia un oggetto di tipo DigitalOut sul pin LED1 e gli da il nome myled
DigitalOut myled(LED1);
+// Instanzia un oggetto di tipo Serial sui pin Tx e Rx della porta USB e gli da il nome pc (trattandosi della porta USB connessa al PC)
+Serial pc(USBTX, USBRX);
+
+// Entry point
int main() {
+ motordir = 1;
- mypwm.period_ms(10);
- mypwm.pulsewidth_ms(1);
+ //Set pwm signal period: The period needed to control the motor in the servo datasheet
+ mypwm.period_ms(10);
+ //mypwm.pulsewidth(0.01); // 100%
+ //mypwm.pulsewidth(0.005); // 50%
+ mypwm.pulsewidth(0.002); // 20%
- printf("pwm set to %.2f %%\n", mypwm.read() * 100);
-
- while(1) {
- myled = !myled;
- wait(1);
- }
-}
+ while(1) {;}
+}
\ No newline at end of file