Using a capacitor in a 1-pin cap-sense button to safe against static

In the old Arduino Playground there was a 1-pin cap sense project that I liked very much but it involved touching a metal pin stuck in an Uno pinhole directly which scares me a little causea static!

My sensor was a thin paperclip bent into a triangle with post shape and foil wrapped on the triangle part, it worked better than a bare pin stuck in the pinhole.

The code sets th pin OUTPUT LOW to ground the sensor then INPUT_PULLUP and count loop till the pin reads HIGH, takes a few 1-microsecond loops to get when there is no touch or finger proximity and 5+ loops on proximity with a jump to more when tpuched.

I put the "sensor" on one leg to a capacitor and plugged the other in the pinhole which changed the number of loops but still worked.

Was I making a static safe touch that way is my big question?

What occurs to me is that this button with timeout not only provides a no moving parts never wears out button but one that can be read magnitudes faster than any bouncy switch!

Please tell me the obvious flaws I totally missed!

ttp223 will solve your doubts.

Not looking to spend more money I may not need to.

I can cover the button and still sense.

Hi @GoForSmoke
Can we see your code please?

I think "static safe" covers a wide range - it depends on the environment.

So the cap was in series between your "sensor" and digital pin - like this?

That is the circuit, I was just trying things out.
I did that so long ago I don't have the code, it was taken from the old Arduino Playground 1 pin capsense example which was later updated by Paul Stofgren.

What Arduino did with the playground is not so nice. But here's the page.

What I did was sort of capacitors in series. IIRC I used an electrolytic maybe 1 uF. This was around 2012-2013.

I must try it.
My best guess on how it works - what do you think?
The logic inputs are virtually infinite (aka very very high) resistance, with a significant but small capacitance to ground, and protection diodes

The input is "grounded" by writing a zero, then o/c by setting it as an input.
When a signal is coupled into that input (without the pull-up) it gets rectified by the protection diode and the cap charges up to a point where it is recognised as a "1".

Well maybe not quite or I miss your description.

The original 1 pin cap sense grounds the pin then sets it to INPUT_PULLUP which weak-sources current into the "sensor". How long that takes to raise the pin HIGH changes when the electric field it makes includes a finger or not.
I slowed it a bit with the paperclip and foil, it makes a bigger field that my finger coupled with from farther away than a straight wire and then I added the cap which slowed it down a bit more but without a touch the time from ground to Uno pin HIGH (2.8V by some posts here) is a few microseconds.
With touch it can be many-many but a timeout at 2 x nuthin can kill the lag. 50 usecs could be enough.

I wonder how much zap the cap might soak up w/o taking the pin past 5V. If it's not enough, I'll cover future buttons with insulator and make them big enough to sense through that.
One thing I picked up from reading is to surround touch spots with ground plane to localize them. There's other tricks with touch shapes to make capacitive "sliders"... there goes the timeout and how peccise could those be? Really there's a whole DIY niche in it just borrowing from what has been done.

Thanks @GoForSmoke a fun and simple experiment

Theoretical parallel plate capacitor has
C= k e0 A / d
where k = relative permittivity of the dielectric (in this case air - about 1)
e0 = 8.9 pF / m
A = area of capacitance in m^2
d = separation in metres.

So the separation needs to be very small. eg insulating tape thickness.

I tried the experiment and -
with a dupont wire about 6cm - 1 cycle
with an A4 aly plate that has an insulating covering - 5 cycles
with my hand on the plate - 12 cycles. near the plate 6 cycles.

Without understanding exactly what is going on it would appear that the native capacitance is increased by capacitive coupling to my body - which has its own capacitance.

The capacitance of a human body is approximately 100 pF

So your additional cap (any value from a few pf upwards) wont harm the performance, and would give protection from conductive effects if the plate is touched; and also provide isolation for the toucher.

I measured the pullup resistor, its about 35k.

AVR docs say it varies from pin to pin, 20K to 50K.

Back in the 80's clothes on office chairs sometimes made for audible snap static but things have changed and computers got hardened against shock.

In my fuzzy learning, inductors slow signal by building a magnetic field so I figure that electrical field is much alike. Long ago closer to 1970 I did read a lot about static electricity and plates but that was in middle school and limited reading plus goofing around.

Thanks for the tighter analysis! I think that insulating cover will be needed. I recall that on a VA hospital ward in winter 2000 we had shoes and carpet that could generate a spark pain when putting a hand on bare metal door knobs. Touching the painted door was enough to bleed the spark off, there's not really much in the spark itself.

Yes, I think I want to move forward with cap sensing when I can see better. It may be better than contact switches. If a capacitive slider can work reliably that could mean many buttons on a pin or two (two if some kind of calibrator is needed) is possible... using digital pins and still be faster than software debounce!