Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions examples/touchsense.ino → examples/touchsense/touchsense.ino
Original file line number Diff line number Diff line change
@@ -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 <Arduino.h>
#include "../libraries/TouchSensor/TouchSensor.h"
Expand All @@ -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)
{
Expand All @@ -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);
}