Gustavo Esteves / Mbed 2 deprecated Questao_3_Slide_Led_Cores

Dependencies:   mbed tsi_sensor

Fork of frdm_tsi_slider by Freescale

main.cpp

Committer:
GustavoRPE
Date:
2016-05-18
Revision:
3:900d47561319
Parent:
2:b13f658fd99f

File content as of revision 3:900d47561319:

#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



int main(void) {
    PwmOut R(LED_RED);
    PwmOut G(LED_GREEN);
    PwmOut B(LED_BLUE);
    TSIAnalogSlider tsi(ELEC0, ELEC1, 1);
            R = 1;
            G = 1;
            B = 1;
    
    while (true) {
        //led = 1.0 - tsi.readPercentage();
        int x = tsi.readPercentage()*100;
        
        if (x>1 && x<20) { //High Temperature
             //- tsi.readPercentage();
            R = 0;
            G = 1;
            B = 1;
            wait(0.1);
            }
        if (x>20 && x<40) { //High Temperature
            R = 1;
            G = 0;
            B = 1;
            wait(0.1);
            }
        if (x>40 && x<60) { //High Temperature
            R = 1;
            G = 1;
            B = 0;
            wait(0.1);
            }
        if (x>60 && x<80) { //High Temperature
            R = 0;
            G = 0;
            B = 1;
            wait(0.1);
            }               
        if (x>80) { //High Temperature
            R = 0;
            G = 1;
            B = 0;
            wait(0.1);
            }
        if (x<1) { //High Temperature
             //- tsi.readPercentage();
            R = 1;
            G = 1;
            B = 1;
            wait(0.1);
            }                   

    }
}