UART Code Example for Serial Communication Workshop - IEEETAMU
Dependencies: mbed tsi_sensor
main.cpp
- Committer:
- MoffMade
- Date:
- 2015-03-06
- Revision:
- 0:d2c37d6f4b0c
File content as of revision 0:d2c37d6f4b0c:
#include "mbed.h" // libraries #include "tsi_sensor.h" #define ELEC0 9 // these are the pin numbers for capacitive touch #define ELEC1 10 Serial pc(USBTX, USBRX); // configure UART pins int main() { pc.baud(9600); //Set baud rate for UART module int sliderValue = 0; // holder variable TSIAnalogSlider tsi(ELEC0, ELEC1, 40); // configure capacitive (CT) touch pins while (true) { // loop forever wait(0.1f); // wait a small period of time pc.printf("Touch Value is: %d\r\n", sliderValue); // print the value sliderValue = (char)(256 * tsi.readPercentage());; // get value from CT } }