ssss
Fork of tsi_sensor by
tsi_sensor.cpp
- Committer:
- pratit911
- Date:
- 2018-05-30
- Revision:
- 11:e8244b68844b
- Parent:
- 10:976904559b5c
File content as of revision 11:e8244b68844b:
#include "mbed.h" #include "tsi_sensor.h" #if defined(TARGET_KL25Z) #define ELEC0 9 #define ELEC1 10 #else #error TARGET NOT DEFINED #endif DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); Serial pc(USBTX, USBRX); PwmOut led1(LED1); PwmOut led2(LED2); PwmOut led3(LED3); float touch; int main(void) { TSIAnalogSlider tsi(ELEC1, ELEC0, 75); while(true) { myled1=1; myled2=1; myled3=1; touch=tsi.readPercentage(); pc.printf("%f\n",touch); if(touch<0.33 && touch>0) {led1=1-touch; myled2=1; myled3=1; wait(0.1); } if(touch>0.33 && touch<0.66) {led2=1-touch; myled3=1; myled1=1; wait(0.1);} if(touch>0.66) {led3=1-touch; myled2=1; myled1=1; wait(0.1);} wait(0.1); } } /*AnalogIn Ain(PTB1); DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); Serial pc(USBTX,USBRX); float ADCdata; int main() { while(1) { ADCdata=Ain; pc.printf("%f \n\r",ADCdata); if(ADCdata>0.4) {myled1=0; myled2=1; myled3=1; } else if((ADCdata>0.4 )&& (ADCdata<0.6)) {myled2=0; myled1=1; myled3=1; } else {myled3=0; myled2=1; myled1=0; } wait(0.005); } }*/