The TSI Analog slider whit light sensor demo for the freedom platform with Kinetis L MCU.
Fork of frdm_tsi_slider by
main.cpp@3:a3161709a1f2, 2014-04-13 (annotated)
- Committer:
- pomernblueice
- Date:
- Sun Apr 13 08:50:23 2014 +0000
- Revision:
- 3:a3161709a1f2
- Parent:
- 2:b13f658fd99f
Obojski;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 0:5d433bc41aba | 1 | #include "mbed.h" |
Kojto | 0:5d433bc41aba | 2 | #include "tsi_sensor.h" |
Kojto | 0:5d433bc41aba | 3 | |
Kojto | 2:b13f658fd99f | 4 | /* This defines will be replaced by PinNames soon */ |
Kojto | 2:b13f658fd99f | 5 | #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) |
Kojto | 0:5d433bc41aba | 6 | #define ELEC0 9 |
Kojto | 0:5d433bc41aba | 7 | #define ELEC1 10 |
Kojto | 0:5d433bc41aba | 8 | #elif defined (TARGET_KL05Z) |
Kojto | 0:5d433bc41aba | 9 | #define ELEC0 9 |
Kojto | 0:5d433bc41aba | 10 | #define ELEC1 8 |
Kojto | 0:5d433bc41aba | 11 | #else |
Kojto | 0:5d433bc41aba | 12 | #error TARGET NOT DEFINED |
Kojto | 0:5d433bc41aba | 13 | #endif |
Kojto | 0:5d433bc41aba | 14 | |
Kojto | 0:5d433bc41aba | 15 | int main(void) { |
pomernblueice | 3:a3161709a1f2 | 16 | PwmOut led2(LED_RED); |
Kojto | 0:5d433bc41aba | 17 | PwmOut led(LED_GREEN); |
Kojto | 2:b13f658fd99f | 18 | TSIAnalogSlider tsi(ELEC0, ELEC1, 40); |
pomernblueice | 3:a3161709a1f2 | 19 | AnalogIn light(PTE22); |
pomernblueice | 3:a3161709a1f2 | 20 | |
Kojto | 0:5d433bc41aba | 21 | |
Kojto | 0:5d433bc41aba | 22 | while (true) { |
pomernblueice | 3:a3161709a1f2 | 23 | led = 1 - tsi.readPercentage(); |
pomernblueice | 3:a3161709a1f2 | 24 | if(light>0.9) led2 = 1.0 - tsi.readPercentage(); else led2=1; |
pomernblueice | 3:a3161709a1f2 | 25 | |
pomernblueice | 3:a3161709a1f2 | 26 | wait(0.1); |
Kojto | 0:5d433bc41aba | 27 | } |
Kojto | 0:5d433bc41aba | 28 | } |