alonso vallejo
/
lab9_TSI
fime
main.cpp@0:227a49f3c678, 2015-05-29 (annotated)
- Committer:
- Alonso
- Date:
- Fri May 29 14:17:16 2015 +0000
- Revision:
- 0:227a49f3c678
lab9 para fime
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Alonso | 0:227a49f3c678 | 1 | #include "mbed.h" |
Alonso | 0:227a49f3c678 | 2 | #include "tsi_sensor.h" |
Alonso | 0:227a49f3c678 | 3 | |
Alonso | 0:227a49f3c678 | 4 | /* This defines will be replaced by PinNames soon */ |
Alonso | 0:227a49f3c678 | 5 | #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) |
Alonso | 0:227a49f3c678 | 6 | #define ELEC0 9 |
Alonso | 0:227a49f3c678 | 7 | #define ELEC1 10 |
Alonso | 0:227a49f3c678 | 8 | #elif defined (TARGET_KL05Z) |
Alonso | 0:227a49f3c678 | 9 | #define ELEC0 9 |
Alonso | 0:227a49f3c678 | 10 | #define ELEC1 8 |
Alonso | 0:227a49f3c678 | 11 | #else |
Alonso | 0:227a49f3c678 | 12 | #error TARGET NOT DEFINED |
Alonso | 0:227a49f3c678 | 13 | #endif |
Alonso | 0:227a49f3c678 | 14 | |
Alonso | 0:227a49f3c678 | 15 | int main(void) { |
Alonso | 0:227a49f3c678 | 16 | PwmOut led1(LED_GREEN); |
Alonso | 0:227a49f3c678 | 17 | PwmOut led2(LED_RED); |
Alonso | 0:227a49f3c678 | 18 | TSIAnalogSlider tsi(ELEC0, ELEC1, 40); |
Alonso | 0:227a49f3c678 | 19 | |
Alonso | 0:227a49f3c678 | 20 | while (true) |
Alonso | 0:227a49f3c678 | 21 | { |
Alonso | 0:227a49f3c678 | 22 | led1 = 1.0 - tsi.readPercentage(); |
Alonso | 0:227a49f3c678 | 23 | led2 = tsi.readPercentage(); |
Alonso | 0:227a49f3c678 | 24 | wait(0.1); |
Alonso | 0:227a49f3c678 | 25 | } |
Alonso | 0:227a49f3c678 | 26 | } |