/** tsi_slider - an example for the tsi_sensor library * * Read the capacitive touch slider of the FRDM-KL25Z board * and control the power of the green LED accordingly. * * Hardware requirements: * - Freescale FRDM-KL25Z board */

Dependencies:   mbed tsi_sensor

Fork of 04_tsi_slider by Istvan Cserny

Revision:
0:fe50a5288858
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 03 07:14:14 2015 +0000
@@ -0,0 +1,21 @@
+/** tsi_slider - an example for the tsi_sensor library
+ *
+ *  Read the capacitive touch slider of the FRDM-KL25Z board
+ *  and control the power of the green LED accordingly.
+ *
+ *  Hardware requirements:
+ *   - Freescale FRDM-KL25Z board
+ */
+
+#include "mbed.h"
+#include "tsi_sensor.h"
+
+int main(void) {
+    PwmOut led(LED_GREEN);              //Configure PWM output for the green LED
+    TSIAnalogSlider tsi(PTB16,PTB17,40);//Configure for the FRDM-KL25Z slider
+    while (true) {
+        float s = tsi.readPercentage(); //Read slider status
+        led = 1.0 - s;                  //Control LED power
+        wait(0.1);                      //wait a little...
+    }
+}
\ No newline at end of file