Zainul Charbiwala
/
TouchSense
Using a capacitor to implement a touch sensitive \"button\"
main.cpp
- Committer:
- zainulcharbiwala
- Date:
- 2010-10-19
- Revision:
- 0:1d63f10fba0a
File content as of revision 0:1d63f10fba0a:
#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; } }