/** TSISensor example program * Read the capacitive touch slider of the FRDM-KL25Z board * and control the power of the blue LED accordingly. * * Hardware requirements: * - Freescale FRDM-KL25Z board */

Dependencies:   TSI mbed

Fork of 04_TSISensor by Istvan Cserny

Committer:
icserny
Date:
Tue Nov 03 06:46:36 2015 +0000
Revision:
1:5ec182dbf86d
Parent:
0:64ba2b612c25
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
icserny 1:5ec182dbf86d 1 /** TSISensor example program
icserny 1:5ec182dbf86d 2 * Read the capacitive touch slider of the FRDM-KL25Z board
icserny 1:5ec182dbf86d 3 * and control the power of the blue LED accordingly.
icserny 1:5ec182dbf86d 4 *
icserny 1:5ec182dbf86d 5 * Hardware requirements:
icserny 1:5ec182dbf86d 6 * - Freescale FRDM-KL25Z board
icserny 1:5ec182dbf86d 7 */
icserny 1:5ec182dbf86d 8
icserny 0:64ba2b612c25 9 #include "mbed.h"
icserny 0:64ba2b612c25 10 #include "TSISensor.h"
icserny 0:64ba2b612c25 11
icserny 0:64ba2b612c25 12 int main(void) {
icserny 1:5ec182dbf86d 13 PwmOut led(LED_BLUE); //Configure a PWM output for the blue LED
icserny 1:5ec182dbf86d 14 TSISensor tsi; //Configure the touch sensing module
icserny 1:5ec182dbf86d 15 led = 1.0; //LED off at the beginning
icserny 0:64ba2b612c25 16 while (true) {
icserny 1:5ec182dbf86d 17 float s = tsi.readPercentage(); //Read slider status
icserny 1:5ec182dbf86d 18 if (s > 0.01) led = 1.0 - s; //Control LED power if touch occurred
icserny 1:5ec182dbf86d 19 wait(0.1); //wait a little...
icserny 0:64ba2b612c25 20 }
icserny 0:64ba2b612c25 21 }