teste

Dependencies:   mbed tsi_sensor

Fork of frdm_tsi_slider by Freescale

main.cpp

Committer:
GustavoRPE
Date:
2016-05-18
Revision:
3:483512a581c6
Parent:
2:b13f658fd99f

File content as of revision 3:483512a581c6:

#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;
            int x = 0;
            
    while (true) {
        //led = 1.0 - tsi.readPercentage();
        

        while (x == 0) {    
        x = tsi.readPercentage()*10;
        wait(0.01);    
        }
        
        if (x > 1) { //High Temperature
             //- tsi.readPercentage();
            R = 0;
            //G = 1;
            //B = 1;
            while (x != 0) {    
                x = tsi.readPercentage()*10;
                wait(0.01);    
                }
            }
        
        while (x == 0) {    
        x = tsi.readPercentage()*10;
        wait(0.01);    
        }
        
        if (x > 1) { //High Temperature
             //- tsi.readPercentage();
            //x = 0;
            R = 1;
            //G = 1;
            //B = 1;
            while (x != 0) {    
                x = tsi.readPercentage()*10;
                wait(0.01);    
                }
               
            }    
                

    }
}