Skip to content

Instantly share code, notes, and snippets.

@reinhrst
Created December 19, 2012 22:57
Show Gist options
  • Save reinhrst/4341358 to your computer and use it in GitHub Desktop.
Save reinhrst/4341358 to your computer and use it in GitHub Desktop.
Capacitive touch on electic imp. Just load the code, and touch pin 1!
//Checks for touch
imp.configure("Touch", [], []);
function test() {
local cycles = 0;
hardware.pin1.configure(DIGITAL_OUT);
hardware.pin1.write(1);
imp.sleep(0.01);
hardware.pin1.configure(DIGITAL_IN);
while (hardware.pin1.read() == 1) {
cycles++;
}
server.show("Took " + cycles + " cycles");
imp.wakeup(0.1, test);
}
test();
@autolibearthled
Copy link

Can it be triggered if a piece of paper is touched it? Looking for a sensor when I place a piece of paper on it the sensor is triggered. Looked at FRS sensors but they need all of the weight right on the sensor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment