![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
COMMIT EMA APROBA CONTROL
Diff: main.cpp
- Revision:
- 0:8cb354c51016
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 28 03:36:27 2019 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" +#include "tsi_sensor.h" + +/* This defines will be replaced by PinNames soon */ +#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) + #define ELEC0 9 + #define ELEC1 10 +#elif defined (TARGET_KL05Z) + #define ELEC0 9 + #define ELEC1 8 +#else + #error TARGET NOT DEFINED +#endif +DigitalOut ledazul(LED_BLUE); +DigitalOut ledverde(LED_GREEN); +DigitalOut ledrojo(LED_RED); +double a=0; +int main(void) { + + TSIAnalogSlider tsi(ELEC0, ELEC1, 100); + + while (true) { + a=tsi.readPercentage(); + if(a>=0.35&&a<=0.65){ + ledazul=0; + } + else + ledazul=1; + + if(a<0.30&&a>0){ + ledverde=0; + } + else + ledverde=1; + + if(a>0.70){ + ledrojo=0; + } + else + ledrojo=1; + + } +}