Alejandro Marin / Tarea7touchcapacitivePWM

Dependencies:   TSI TextLCD 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  
00006 float value=0,valuev=0;
00007 TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7
00008  
00009 int main(void) {
00010 
00011     //lcd.writeCommand(0x0E);
00012    
00013     
00014     PwmOut led(LED_BLUE);
00015     PwmOut pin(PTD4);
00016     float p=0.003;
00017     led.period(p);
00018     //pin.pulsewidth(p);
00019     pin.period(p);
00020     lcd.printf("Periodo=%gs",p);
00021     lcd.locate(0,1);
00022     lcd.printf("cycle duty=0");
00023     TSISensor tsi;
00024     led = 1;
00025     int d;
00026     while (true) {
00027     value=tsi.readPercentage();
00028     if(value!=valuev && value!=0)
00029     {
00030     
00031        // pin = 1.0 - value;
00032         pin.write(1.0 - value);  
00033         led.write(value);        
00034         d=(1-value)*100;
00035         lcd.locate(0,1);
00036         lcd.printf("                ");
00037         lcd.locate(0,1);
00038         lcd.printf("cycle duty=%d",d);
00039         valuev=value;        
00040     }
00041    // wait(0.1);
00042     
00043 }
00044 }