Controlling Blinking frequency using TSI Slider

Dependencies:   mbed tsi_sensor

Committer:
sivaieee
Date:
Mon Nov 14 19:15:24 2016 +0000
Revision:
5:feab406f054b
Parent:
4:fe602d6e48d9
Modified TSI Blinky

Who changed what in which revision?

UserRevisionLine numberNew 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) {
Kojto 0:5d433bc41aba 16 PwmOut led(LED_GREEN);
Kojto 2:b13f658fd99f 17 TSIAnalogSlider tsi(ELEC0, ELEC1, 40);
sivaieee 3:a47ba029fe08 18 float x;
sivaieee 5:feab406f054b 19 x = 0.1;
Kojto 0:5d433bc41aba 20 while (true) {
sivaieee 3:a47ba029fe08 21 led = !led;
sivaieee 3:a47ba029fe08 22 wait(x);
sivaieee 3:a47ba029fe08 23 x = tsi.readPercentage();
sivaieee 5:feab406f054b 24
Kojto 0:5d433bc41aba 25 }
Kojto 0:5d433bc41aba 26 }