COMMIT EMA APROBA CONTROL

Dependencies:   mbed

Committer:
Jalle
Date:
Thu Nov 28 03:36:27 2019 +0000
Revision:
0:8cb354c51016
COMMIT EMA TE QUEREMOS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jalle 0:8cb354c51016 1 #include "mbed.h"
Jalle 0:8cb354c51016 2 #include "tsi_sensor.h"
Jalle 0:8cb354c51016 3
Jalle 0:8cb354c51016 4 /* This defines will be replaced by PinNames soon */
Jalle 0:8cb354c51016 5 #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
Jalle 0:8cb354c51016 6 #define ELEC0 9
Jalle 0:8cb354c51016 7 #define ELEC1 10
Jalle 0:8cb354c51016 8 #elif defined (TARGET_KL05Z)
Jalle 0:8cb354c51016 9 #define ELEC0 9
Jalle 0:8cb354c51016 10 #define ELEC1 8
Jalle 0:8cb354c51016 11 #else
Jalle 0:8cb354c51016 12 #error TARGET NOT DEFINED
Jalle 0:8cb354c51016 13 #endif
Jalle 0:8cb354c51016 14 DigitalOut ledazul(LED_BLUE);
Jalle 0:8cb354c51016 15 DigitalOut ledverde(LED_GREEN);
Jalle 0:8cb354c51016 16 DigitalOut ledrojo(LED_RED);
Jalle 0:8cb354c51016 17 double a=0;
Jalle 0:8cb354c51016 18 int main(void) {
Jalle 0:8cb354c51016 19
Jalle 0:8cb354c51016 20 TSIAnalogSlider tsi(ELEC0, ELEC1, 100);
Jalle 0:8cb354c51016 21
Jalle 0:8cb354c51016 22 while (true) {
Jalle 0:8cb354c51016 23 a=tsi.readPercentage();
Jalle 0:8cb354c51016 24 if(a>=0.35&&a<=0.65){
Jalle 0:8cb354c51016 25 ledazul=0;
Jalle 0:8cb354c51016 26 }
Jalle 0:8cb354c51016 27 else
Jalle 0:8cb354c51016 28 ledazul=1;
Jalle 0:8cb354c51016 29
Jalle 0:8cb354c51016 30 if(a<0.30&&a>0){
Jalle 0:8cb354c51016 31 ledverde=0;
Jalle 0:8cb354c51016 32 }
Jalle 0:8cb354c51016 33 else
Jalle 0:8cb354c51016 34 ledverde=1;
Jalle 0:8cb354c51016 35
Jalle 0:8cb354c51016 36 if(a>0.70){
Jalle 0:8cb354c51016 37 ledrojo=0;
Jalle 0:8cb354c51016 38 }
Jalle 0:8cb354c51016 39 else
Jalle 0:8cb354c51016 40 ledrojo=1;
Jalle 0:8cb354c51016 41
Jalle 0:8cb354c51016 42 }
Jalle 0:8cb354c51016 43 }