genera un PWM con ancho de pulso variable a traves del touchcapacitive integrado en la tarjeta kl25z
Dependencies: TSI TextLCD mbed
main.cpp
- Committer:
- amarincan
- Date:
- 2013-12-11
- Revision:
- 0:ae7305f55ecf
File content as of revision 0:ae7305f55ecf:
#include "mbed.h" #include "TSISensor.h" #include "TextLCD.h" float value=0,valuev=0; TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 int main(void) { //lcd.writeCommand(0x0E); PwmOut led(LED_BLUE); PwmOut pin(PTD4); float p=0.003; led.period(p); //pin.pulsewidth(p); pin.period(p); lcd.printf("Periodo=%gs",p); lcd.locate(0,1); lcd.printf("cycle duty=0"); TSISensor tsi; led = 1; int d; while (true) { value=tsi.readPercentage(); if(value!=valuev && value!=0) { // pin = 1.0 - value; pin.write(1.0 - value); led.write(value); d=(1-value)*100; lcd.locate(0,1); lcd.printf(" "); lcd.locate(0,1); lcd.printf("cycle duty=%d",d); valuev=value; } // wait(0.1); } }