PWM motor controler. Serial DAQ float 0 upto 1

Dependencies:   mbed

main.cpp

Committer:
kanatronics
Date:
2016-06-24
Revision:
0:d26101f286c4
Child:
1:a3dae8744a7d

File content as of revision 0:d26101f286c4:

/*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; 
     }
    }
   }
  }