Skip to content

Instantly share code, notes, and snippets.

@rbaron
Created March 9, 2021 20:42
Show Gist options
  • Save rbaron/36cc9aa1fec0120e06cd2ca3fadadaaa to your computer and use it in GitHub Desktop.
Save rbaron/36cc9aa1fec0120e06cd2ca3fadadaaa to your computer and use it in GitHub Desktop.
A quick-and-dirty Arduino sketch for reading capacitive touch values.
#define N_SAMPLES 64
void setup()
{
Serial.begin(9600);
while (!Serial) delay(10);
}
void loop()
{
int out = 0;
for (int i = 0; i < N_SAMPLES; i++) {
out += touchRead(T0);
}
Serial.println((double) out / N_SAMPLES);
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment