Help please. I only have 1 pin spare and I would like it to be a capacitive touch sensor. I believe I need the <ADCTouch.h> library and that the pin needs to be A0-A5. I would like to be able to illuminate/ distinguish an LED by touching copper please.
What happens when you simply try it out?
Nothing, Below is the only info I can find and its not enought info for my small mind to be able to figure out what to do....
int val = ADCTouch.read(byte analogChannel, int samples = 100);
analogChannel: the pin to use, you can just use A0 - A5
samples: (optional) the amount of samples to take, defaults to 100
...range 1 - 65535 ...(value does not change with different amounts of samples)
How it works
To Acquire a reading, the library does the following:
charge the test pin to 5V via pullup resistor (not directly to prevent short circuits)
discharge the internal ~14pF capacitor
set the pin to tristate
connect the 14pF capacitor with the pin so that charge distributes evenly
measure the voltage of the internal cap with analogRead()
...if the pin has a low capacitance, the stored charge will be small as will the resulting voltage, if the external capacitance is equal to 14pF, the volatage should be ~2.5V. Even higher capacitances will result in volatges > 2.5V. The chip and arduino board already have stray capacitances that will produce an output of ~390 and just a single external wire can boost that up to 500, so you really need offset compensation.
The accuracy is really good, most often even the LSB/smalles digit can still yield usable data and just vary by a single unit between readings (at only 100 samples, more will mean even less variation). The sensitivity is phenomenal, with a large enough surface, it can sense a person in more than 2 feet distance.
A more accurate explanation can be found here
This comes up,
"
_8LEDsV12:68: error: expected primary-expression before 'analogChannel'
int val = ADCTouch.read(byte analogChannel, int samples = 100);
^
_8LEDsV12:68: error: expected primary-expression before 'int'
int val = ADCTouch.read(byte analogChannel, int samples = 100);
^
exit status 1
expected primary-expression before 'analogChannel'"
Those variable declarations don't belong there indeed. It's a syntax error.