Control de velocidad y dirección de giro de un motor PAP con la tarjeta F407. Se incluyen las librerías con la clase Motor.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mainpwm.cpp Source File

mainpwm.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut IzqDireccion(PD_13);
00004 DigitalOut LED(PD_14);
00005 DigitalOut DerDireccion(PD_11);
00006 
00007 
00008 PwmOut Speed(PB_15);
00009 
00010 int main() {
00011     
00012     Speed.period_ms(5);
00013     
00014     while(1)
00015      {
00016         
00017      /// direccion 1   
00018         LED = 1;
00019         IzqDireccion = 1;
00020         DerDireccion = !IzqDireccion;
00021         wait_ms(100);
00022         
00023         /// Speed setting   
00024         for(int i = 0; i < 100; i ++)
00025         {
00026             Speed.write(float(i/100.0));
00027             wait(1);
00028             
00029             }
00030             
00031       /// Set a 0      
00032         IzqDireccion = 0;
00033         DerDireccion = 0;
00034         wait_ms(100);
00035     
00036     /// Direccion 2    
00037         LED = 0;
00038         IzqDireccion = 0;
00039         DerDireccion = !IzqDireccion;
00040         wait_ms(100);
00041         
00042         // Speed Setting
00043         for(int i = 0; i < 10; i ++)
00044         {
00045             Speed.write(float(i/100.0));
00046             wait(1);
00047             
00048             }
00049             
00050      /// Set to 0       
00051         IzqDireccion = 0;
00052         DerDireccion = 0;
00053         wait_ms(100);
00054     }
00055 }