pwm con touchpad

Dependencies:   TSI TextLCD3 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TSISensor.h"
00003 #include "TextLCD.h"
00004  
00005 PwmOut led(LED1);
00006 PwmOut led2(PTA5);
00007 
00008 TextLCD lcd(PTB10,PTB11,PTE2,PTE3,PTE4,PTE5);
00009  
00010 float a = 0.0;
00011 float l;
00012 int main() {
00013 led.period(0.02); 
00014 led2.period(0.02);         
00015        
00016 TSISensor tsi;
00017 
00018 float b = 0.0;
00019 
00020     while(1) {
00021        a = tsi.readPercentage();
00022        if (tsi.readPercentage()){
00023        l = a;
00024        }
00025       
00026        b = 0.001 + (l);// ancho de pulso
00027       
00028        
00029         // servo position determined by a pulsewidth between 1-2ms
00030         
00031         led = 1.0 - l; 
00032         led2 = 1.0 - l;
00033         lcd.locate(0,0);      //localizar en la columna, fila de la LCD
00034         lcd.printf("med:%0.3f", a);
00035         lcd.locate(9,0);      //localizar en la columna, fila de la LCD
00036         lcd.printf("p(ms):%d", 20);
00037         lcd.locate(0,1);      //localizar en la columna, fila de la LCD
00038         lcd.printf("D:%0.3f", b);
00039         wait(0.25);
00040     }  
00041 }