Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <CapacitiveSensor.h>
- /*
- * Based on the CapitiveSense Library Demo Sketch
- * which was written by Paul Badger 2008
- * Uses a high value resistor (in this case, 750k ohm) between send pin and receive pin
- * Resistor effects sensitivity, Larger resistor values yield larger sensor values.
- * Receive pin is the sensor pin
- - Final sketch written by Brian Schulteis - The UnaClocker, November 2013
- - Uses an ATTiny85 running at 8MHz on the internal oscillator, to control an XBox 360 power supply
- - 5v is provided by the 5v standby power of the XBox 360 power supply.
- */
- boolean lightOn=false; // I like booleans
- CapacitiveSensor tapper = CapacitiveSensor(0,1); // 750k resistor between pins 0 & 1, pin 1 is sensor pin
- unsigned long lastTap; // Used as a kind of a debounce effect
- void setup()
- {
- pinMode(3, OUTPUT);
- digitalWrite(3, lightOn);
- lastTap=millis();
- }
- void loop()
- {
- if (tapper.capacitiveSensor(30) > 50) {
- if ((millis()-lastTap)>500) {
- lightOn=!lightOn;
- lastTap=millis();
- }
- }
- delay(50);
- digitalWrite(3, lightOn);
- delay(100); // arbitrary delay to limit oversampling the pin
- // May cause quick taps to be missed, that's ok by me.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement