Using a capacitor to implement a touch sensitive \"button\"

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
zainulcharbiwala
Date:
Tue Oct 19 00:08:04 2010 +0000
Commit message:
Initial upload of TouchSense

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 19 00:08:04 2010 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+
+#define numsamples 1
+int touchSense(void);
+
+DigitalOut myled(LED1);
+AnalogIn input(p20);
+DigitalIn charger(p19);
+DigitalOut ground(p18);
+Serial pc(USBTX, USBRX); // tx, rx
+    
+int main() {
+  while(1) {
+    if (touchSense()) {
+        myled = 1;
+    } else {
+        myled = 0;
+    }
+  wait(0.005);
+  }
+}
+
+int touchSense(void)
+{
+    float sample;
+    ground = 0;
+    charger.mode(PullUp);
+    charger.mode(PullNone);
+    sample=input.read();
+    if (sample < 0.3) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 19 00:08:04 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e