Pratit Nayak
/
tsi_name
tsi name
main.cpp@0:691801d15035, 2018-05-30 (annotated)
- Committer:
- pratit911
- Date:
- Wed May 30 07:12:53 2018 +0000
- Revision:
- 0:691801d15035
tsi name
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pratit911 | 0:691801d15035 | 1 | #include "mbed.h" |
pratit911 | 0:691801d15035 | 2 | #include "tsi_sensor.h" |
pratit911 | 0:691801d15035 | 3 | #if defined(TARGET_KL25Z) |
pratit911 | 0:691801d15035 | 4 | #define ELEC0 9 |
pratit911 | 0:691801d15035 | 5 | #define ELEC1 10 |
pratit911 | 0:691801d15035 | 6 | #else |
pratit911 | 0:691801d15035 | 7 | #error TARGET NOT DEFINED |
pratit911 | 0:691801d15035 | 8 | #endif |
pratit911 | 0:691801d15035 | 9 | DigitalOut myled1(LED1); |
pratit911 | 0:691801d15035 | 10 | DigitalOut myled2(LED2); |
pratit911 | 0:691801d15035 | 11 | DigitalOut myled3(LED3); |
pratit911 | 0:691801d15035 | 12 | Serial pc(USBTX, USBRX); |
pratit911 | 0:691801d15035 | 13 | float touch; |
pratit911 | 0:691801d15035 | 14 | int main(void) |
pratit911 | 0:691801d15035 | 15 | { |
pratit911 | 0:691801d15035 | 16 | TSIAnalogSlider tsi(ELEC1, ELEC0, 75); |
pratit911 | 0:691801d15035 | 17 | |
pratit911 | 0:691801d15035 | 18 | while(true) |
pratit911 | 0:691801d15035 | 19 | { |
pratit911 | 0:691801d15035 | 20 | myled1=1; |
pratit911 | 0:691801d15035 | 21 | myled2=1; |
pratit911 | 0:691801d15035 | 22 | myled3=1; |
pratit911 | 0:691801d15035 | 23 | touch=tsi.readPercentage(); |
pratit911 | 0:691801d15035 | 24 | |
pratit911 | 0:691801d15035 | 25 | |
pratit911 | 0:691801d15035 | 26 | if(touch<0.33 && touch>0) |
pratit911 | 0:691801d15035 | 27 | {myled1=0; |
pratit911 | 0:691801d15035 | 28 | myled2=1; |
pratit911 | 0:691801d15035 | 29 | myled3=1; |
pratit911 | 0:691801d15035 | 30 | pc.printf("PRATIT\n"); |
pratit911 | 0:691801d15035 | 31 | wait(0.1);} |
pratit911 | 0:691801d15035 | 32 | |
pratit911 | 0:691801d15035 | 33 | if(touch>0.33 && touch<0.66) |
pratit911 | 0:691801d15035 | 34 | {myled1=1; |
pratit911 | 0:691801d15035 | 35 | myled2=0; |
pratit911 | 0:691801d15035 | 36 | myled3=1; |
pratit911 | 0:691801d15035 | 37 | pc.printf("NAYAK\n"); |
pratit911 | 0:691801d15035 | 38 | wait(0.1);} |
pratit911 | 0:691801d15035 | 39 | |
pratit911 | 0:691801d15035 | 40 | if(touch>0.66) |
pratit911 | 0:691801d15035 | 41 | {myled1=1; |
pratit911 | 0:691801d15035 | 42 | myled2=1; |
pratit911 | 0:691801d15035 | 43 | myled3=0; |
pratit911 | 0:691801d15035 | 44 | pc.printf("POKHARIPUT\n"); |
pratit911 | 0:691801d15035 | 45 | wait(0.1);} |
pratit911 | 0:691801d15035 | 46 | |
pratit911 | 0:691801d15035 | 47 | wait(0.1); |
pratit911 | 0:691801d15035 | 48 | } |
pratit911 | 0:691801d15035 | 49 | } |