PWM motor controler. Serial DAQ float 0 upto 1

Dependencies:   mbed

Revision:
0:d26101f286c4
Child:
1:a3dae8744a7d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 24 14:54:11 2016 +0000
@@ -0,0 +1,32 @@
+/*Kamil Kanas 
+Nucleo  PWM to Serial motor controller 
+Tested 24/6/2016
+*/
+
+#include "mbed.h"
+#define led_green D13    
+//DigitalOut green(led_green);        
+Serial pc(USBTX,USBRX);
+PwmOut led(D13);
+  
+float pwmOut;
+char buffer[16];  
+
+int main() {
+    pc.baud(115200);                                  /*Set baud rate*/
+    
+      while (1){
+       led=pwmOut;
+       while(true){
+       if(pc.readable()) {                           /*if data in the ring buffer*/   
+         pc.gets(buffer, 8);
+          pc.printf("DataReceived %s \n", buffer);  
+          //dataInt = atoi(buffer);
+          //pc.printf("%d \n",dataInt); 
+           pwmOut=atof(buffer);
+            pc.printf("%2.2f\n",pwmOut);
+          break; 
+     }
+    }
+   }
+  }  
\ No newline at end of file