pwm para etapa de potencia

Dependencies:   TextLCD mbed

Fork of TutoElectro_PWM by Alejandro M

main.cpp

Committer:
josedaparte
Date:
2015-12-07
Revision:
3:7de9f8f4a15e
Parent:
2:be4ea24f1cdd

File content as of revision 3:7de9f8f4a15e:

#include "mbed.h"
#include "TextLCD.h"
#include "AnalogIn.h"
PwmOut pwmsal(PTD2);
AnalogIn pwment(PTB1);
Serial pc(USBTX,USBRX);
float valorpwm;
TextLCD lcd(PTD3, PTA12, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2);
AnalogIn presionin(PTB3);
float caspresion;


int main()
{
    
    while(1){
    
      caspresion = presionin.read() * 3.3;
        lcd.cls();
        lcd.locate(0,1);
        lcd.printf("%.2f",caspresion);
        
        if(caspresion >= 2.34){
            lcd.locate(0,0);
            lcd.printf("maximo");
            }
        
        if(caspresion >= 1.68 && caspresion <= 1.85){
            lcd.locate(0,0);
            lcd.printf("medio");
            }
        
        if(caspresion <= 1.03){
            lcd.locate(0,0);
            lcd.printf("minimo");
            }    
        
    pc.baud(115200);
    pwmsal.period(5);
    valorpwm = pwment.read();
    pwmsal.write(valorpwm);
    wait(1);
    }
}