diff --git a/examples/touchsense.ino b/examples/touchsense/touchsense.ino similarity index 95% rename from examples/touchsense.ino rename to examples/touchsense/touchsense.ino index f763f0b..caa2138 100644 --- a/examples/touchsense.ino +++ b/examples/touchsense/touchsense.ino @@ -1,8 +1,8 @@ -/** - This example uses the TouchSensor library to sense touch on a metal pad connected to a digital pin. +/** + This example uses the TouchSensor library to sense touch on a metal pad connected to a digital pin. - For details see the documentation.txt file. -*/ + For details see the documentation.txt file. +*/ #include #include "../libraries/TouchSensor/TouchSensor.h" @@ -23,10 +23,10 @@ int kIndicator = 13; // digital pin for LED to indicate touch #ifdef debug - // pins are in this order: reset, dc (d/c), sdin (mosi - data in), sclk (sck - clock), sce (chip enable), led (backlight) + // pins are in this order: reset, dc (d/c), sdin (mosi - data in), sclk (sck - clock), sce (chip enable), led (backlight) nokiaLCD display(10,11,12,13,7,6); -#endif - +#endif + bool testTouch(TouchSensor& sensor) { @@ -50,43 +50,43 @@ bool testTouch(TouchSensor& sensor) return isTouched; } - - - + + + //TouchSensor& sensor = touchChargeInt; //TouchSensor& sensor = touchChargeExt; //TouchSensor& sensor = touchDischarge; - - -void setup() -{ + + +void setup() +{ #ifdef debug Serial.begin(9600); Serial << "Starting..." << endl; display.init(); - display.backlight(true); + display.backlight(true); display.home(); display << "Ready" << endl; -#endif +#endif //delay(500); sensor.setThreshold(100); sensor.setSampleSize(100); - sensor.establishBaseline(); - - pinMode(kIndicator, OUTPUT); // init indicator led -} - -void loop() -{ + sensor.establishBaseline(); + + pinMode(kIndicator, OUTPUT); // init indicator led +} + +void loop() +{ bool touched = testTouch(sensor); if (!touched) - touched = sensor.switchPressed(); - - digitalWrite(kIndicator, touched); - - delay(200); -} - - + touched = sensor.switchPressed(); + + digitalWrite(kIndicator, touched); + + delay(200); +} + +