PWM, ancho de pulso variable, periodo variable (lectura por puerto)

Dependencies:   TSI TextLCD mbed

main.cpp

Committer:
avallejopo
Date:
2013-11-29
Revision:
0:c1fa75d95078

File content as of revision 0:c1fa75d95078:

#include "mbed.h"
#include "TSISensor.h"
#include "TextLCD.h"

TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7
Timer t1;
float anchop=0.5;
float periodo=100;
int main(void) {

    PwmOut led(PTA5);
    TSISensor tsi;
    led.pulsewidth(anchop);
    led.period_ms(periodo);
    
    while (true) {
        if(tsi.readPercentage()!=0){
            led = 1.0 - tsi.readPercentage();
            lcd.cls();
            lcd.printf("PWM=%g",tsi.readPercentage());
        }        
        wait(0.1);
    }
}