sample program for TTP229 16key touch keypad

Dependencies:   TTP229 mbed

sample program for TTP229 library

pin connection

PC     mbed LPC1768        TTP229
           P22 ----------- SDO
           P21 ----------- SCL
          3.3V ----------- VCC
           GND ----------- GND
USB ------ USB(UART)
Revision:
0:4f0200333d59
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jul 16 11:20:34 2016 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+#include "TTP229.h"
+
+//DigitalOut myled(LED1);
+//DigitalOut myled2(LED2);
+//DigitalOut myled3(LED3);
+BusOut myleds(LED1, LED2, LED3, LED4);
+
+TTP229 touchpad(p22,p21);
+
+string to_string(const bitset<16>& bs)
+{
+    return bs.to_string<char, std::char_traits<char>, std::allocator<char> >();
+}
+
+void ttp229int()
+{
+    printf("%16s\r\n",to_string(touchpad).c_str());
+    //printf("%d\r\n",touchpad.onkey());
+    //int sw=touchpad.getsingle();
+    //if(sw!=0) myleds=sw%16;
+}
+
+int main()
+{
+    printf("Hello TTP229\r\n");
+    touchpad.attach(&ttp229int);
+    while(1) {
+        for(int i=0; i<4; i++) {
+            myleds[i]=touchpad[(i+1)*4-1];
+        }
+        wait(0.5);
+    }
+}