/** 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
00001 /** TSISensor example program 00002 * Read the capacitive touch slider of the FRDM-KL25Z board 00003 * and control the power of the blue LED accordingly. 00004 * 00005 * Hardware requirements: 00006 * - Freescale FRDM-KL25Z board 00007 */ 00008 00009 #include "mbed.h" 00010 #include "TSISensor.h" 00011 00012 int main(void) { 00013 PwmOut led(LED_BLUE); //Configure a PWM output for the blue LED 00014 TSISensor tsi; //Configure the touch sensing module 00015 led = 1.0; //LED off at the beginning 00016 while (true) { 00017 float s = tsi.readPercentage(); //Read slider status 00018 if (s > 0.01) led = 1.0 - s; //Control LED power if touch occurred 00019 wait(0.1); //wait a little... 00020 } 00021 }
Generated on Wed Jul 13 2022 13:24:17 by 1.7.2