UART Code Example for Serial Communication Workshop - IEEETAMU

Dependencies:   mbed tsi_sensor

Revision:
0:d2c37d6f4b0c
diff -r 000000000000 -r d2c37d6f4b0c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 06 21:40:15 2015 +0000
@@ -0,0 +1,18 @@
+#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
+    }
+}