/** 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 */
/ 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
- /
main.cpp
- Committer:
- icserny
- Date:
- 2015-11-03
- Revision:
- 1:5ec182dbf86d
- Parent:
- 0:64ba2b612c25
File content as of revision 1:5ec182dbf86d:
/** 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 */ #include "mbed.h" #include "TSISensor.h" int main(void) { PwmOut led(LED_BLUE); //Configure a PWM output for the blue LED TSISensor tsi; //Configure the touch sensing module led = 1.0; //LED off at the beginning while (true) { float s = tsi.readPercentage(); //Read slider status if (s > 0.01) led = 1.0 - s; //Control LED power if touch occurred wait(0.1); //wait a little... } }