A simple touch sensor that sends a message to computer when it notices touch. I'm using a simple voltage divider with 10k resistor and body impedance.

Dependencies:   mbed

Committer:
Vekotin
Date:
Fri Jan 24 14:32:15 2014 +0000
Revision:
0:9720755e6762
Child:
1:7ed7d128d225
Simple touch sensor sends a message to computer when it notices touch. I'm using a simple voltage divider with 10k resistor and body impedance.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Vekotin 0:9720755e6762 1 //Almighty Vekotin v.1.0
Vekotin 0:9720755e6762 2
Vekotin 0:9720755e6762 3 #include "mbed.h"
Vekotin 0:9720755e6762 4
Vekotin 0:9720755e6762 5 AnalogIn ain(p16);
Vekotin 0:9720755e6762 6 Serial pc(USBTX, USBRX);
Vekotin 0:9720755e6762 7 float input;
Vekotin 0:9720755e6762 8
Vekotin 0:9720755e6762 9 int main() {
Vekotin 0:9720755e6762 10 while (1){
Vekotin 0:9720755e6762 11
Vekotin 0:9720755e6762 12 input = ain.read(); //reads input in p16
Vekotin 0:9720755e6762 13 //without touch input is HIGH (1)
Vekotin 0:9720755e6762 14 if (input < 1){ //with touch input changes its value
Vekotin 0:9720755e6762 15 pc.printf("TOUCH!");
Vekotin 0:9720755e6762 16 }
Vekotin 0:9720755e6762 17
Vekotin 0:9720755e6762 18 wait(0.25);
Vekotin 0:9720755e6762 19
Vekotin 0:9720755e6762 20 }
Vekotin 0:9720755e6762 21 }