![](/media/cache/profiles/23d3743ad75e4470e7ff7129351a9541.jpg.50x50_q85.jpg)
Touch Pad example with USB Serial function.
Diff: main.cpp
- Revision:
- 0:1831ea7044ec
- Child:
- 1:dd12cd8c2fab
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 19 18:44:05 2015 +0000 @@ -0,0 +1,50 @@ +/****************************************************************** +Program: MyFirstMbed +Author: CTalbot +Date: 19 Feb, 2015 +(c) Fanshawe College, 2015 +Modified: Xxxxxxx Xxxxxx + +Description: This program introduces the touch pad of the FRDM-KL25Z, + and USB serial function. Hello World. +********************************************************************/ + +// Preprocessor Statements +#include "mbed.h" +#include "tsi_sensor.h" + +// Constants + + + +// Global Variables + +Serial pc(USBTX, USBRX); // USE Serial Port + + +/*** MAIN *************************************************************/ +int main() +{ + PwmOut Grn(LED_GREEN); // PWM output, named Grn, tied to LED_GREEN Pin + PwmOut Red(LED_RED); + PwmOut Blue(LED_BLUE); + + TSIAnalogSlider tsi(PTB16, PTB17, 25); // Touch pad slider tied to touch pad pins, named tsi + + while(1) + { + Grn = 1.0 - tsi.readPercentage(); // Assign the read value taken away from 1 to Grn. + Red = tsi.readPercentage(); + Blue = tsi.readPercentage() / 2; + + pc.printf("\033[2J"); // clears the entire terminal screen. + pc.printf("\033[H"); // Sends cursor to home position, 0,0 + + pc.printf("\n\rHello World"); + pc.printf("\n\rName: CTalbot"); + pc.printf("\n\rTouch Pad Value: %.2f", tsi.readPercentage() ); + + wait(0.2); + + } +}