In a way. Very clever science is magic, right?

Show me what you're talking about

Well, it's a way of making a button where instead of pushing a button, you make a magical* connection with your finger and a special surface.

*ok, science.

touch pHAT

We use it in loads of our HATs and pHATs, most noticeably in the Touch pHAT and in the Drum HAT.

me poking the drum HAT

What's it made of?

copper pads

If you need to know if something has been prodded, you can use a copper pad. The pad is charged with a tiny voltage, which makes an electrical field over the pad.

For some capacitive touch buttons you have to actually touch the pad, but with others you can just be very close to it. This is how we are able to put paint over the top of the pads and still have a working Touch pHAT. Your finger is an electrical conductor, and as such it can interfere with electrostatic fields.

How does your finger interfere with the field?

electrostatic field

Here is an, ahem, artists representation of the electrostatic field, and what happens when you poke your finger in it.

You can see an electrical field if you happen to have a plasma ball and your hand. You can see that where you touch the globe, the field changes.

plasma ball being touched by hand

Each touch pad has an electrical field, and when you poke something conductive (like a finger) at the field, the change is detected and the switch triggered.

How does it know you've touched it?

The software constantly checks the voltage on all the pads to see if everything is as it was last time it checked. It's a bit like a security guard going round checking. As soon as something is different, they sound the alarm. Just as the guard might say "breach in Sector 4!", the software registers where the change was, and counts this as a button press.

breach in sector 4
On our boards we use a chip called a CAP1166 which can process the information from up to six touch inputs. If you look closely on the underneath you can see it - the square one on the right with C1166 written on.

back of touch phat

Brief Interlude - what's a capacitor?

A capacitor is made of two conductive plates. You can change the capacitance by changing the size of the plates and the distance they are apart.

Usually there are two plates, but in this case the copper pad is one plate, and the surroundings are the other plate. This makes a particularly bad capacitor (low capacitance).

When you poke the pad, all of you becomes the second plate! Yes, you. Because you are mostly water, you make a pretty good conductor, and therefore the capacitor becomes a much better capacitor (higher capacitance).

How does the chip measure whether the capacitance has changed?

The steps that it goes through are:

  1. Make the copper pad at 0V (no charge)
  2. Charge up an internal capacitor (a separate one to the touch pad) to 3V (some charge).

buckets of charge

  1. Now they are both charged up, they are connected together. If the pad isn't being touched, that little charge that was on the internal capacitor will ploop over and spread onto the pad, and the voltage gets measured. This is what counts as "normal" for the chip.

normal ploop

  1. If the pad is being touched, that little charge will ploop over to the pad and will also spread out all over you (ya big capacitor plate, you), and when the chip measures the voltage this time it has dropped lower (because you made it have a higher capacitance) and it can tell.

not normal ploop

So now you know how your body can interfere with electrical fields and cause a measurable effect, which in turn can be detected and turned into an electrical signal and used to control processes.

Kind of magic.

HATs and pHATs used:
Touch pHAT
Explorer HAT Pro
Drum HAT
Piano HAT
Rainbow HAT