There are no switches on it. Each printed pad is one plate of a capacitor and your finger is the other, and the Tontek TTP229-BSF on the back watches all sixteen. It reports them through its own two-wire serial interface, which is not I2C and not SPI, and in 8-key mode also on eight direct outputs.
Pins
| Pin | What it does |
|---|---|
VCC |
Supply, 2.4 V to 5.5 V. |
GND |
Ground. |
SCL |
Serial clock in, driven by the board. |
SDO |
Serial data out: one key per clock pulse, low while touched. |
OUT1 to OUT8 |
Direct outputs for keys 1 to 8, high while touched. 8-key mode only. |
Properties
The board's option pads, "LINK=0, UNLINKED=1", are settings here. Like the real chip, a change takes effect when the circuit starts.
keys is the TP2 pad: 8 (open, as shipped) or 16 (linked). In 8-key mode pads 9
to 16 are the chip's direct outputs, so they are not keys and the serial frame is 8
bits. In 16-key mode all sixteen pads are keys and the OUT pins float. Almost every
tutorial links TP2 first.
activehigh is the TP1 pad. Open, as shipped, the serial interface is active low
(SCL and SDO idle high, a touched key reads 0) and the direct outputs are active
high. Linked, every one of those flips.
multikey is the TP3 and TP4 pads linked together. Open, as shipped, the chip
reports one key at a time, the first in scan order from key 1. Linked, it reports
every key that is touched.
While it runs
Press the pads. Several can be held at once, and each key can have its own keyboard
key in the part panel. The finger shows at once; the pad lights when the chip
reports it, one scan later. In 8-key mode pads 9 to 16 are dimmed. The TP2 pads at
the top right are bridged in 16-key mode.
What the model gets right
The serial frame, from the datasheet. Each clock pulse on SCL puts the next key
on SDO, key 1 first, 16 bits or 8. With TP1 open a pulse starts on the falling
edge, so the library's "SCL low, read SDO, SCL high" reads one key per pulse. If
SCL sits still for 2 ms (Tout) the interface resets and the next pulse is key 1
again. The sheet allows 1 kHz to 512 kHz on SCL.
Data valid. While a key is touched, SDO pulses low for 93 µs once a scan (DV),
and the first clock may come 10 µs after it ends. A library that waits for a touch
waits for this pulse. The sheet does not say whether DV comes with no key touched;
here it does not, which is how the library's blocking read behaves on a real board.
Timing. A touch or a release shows at the next scan: 32 ms with 16 keys, 16 ms with 8, the sheet's response time. For about half a second after power the keys are off while the chip calibrates. A finger still on a pad when that ends was measured as part of the pad, and counts only once it lifts and comes back.
The library
#include <TTP229.h> with TTP229 ttp229(SCL_PIN, SDO_PIN) is the library the red
board's tutorials use (arduino12's ttp229b-arduino): ReadKey16() waits for a touch
and returns the key, 1 to 16; GetKey16() waits up to about 50 ms and returns the
last key if none came; ReadKeys16() and GetKeys16() return every key as bits,
bit 0 for key 1. ReadKey8(), GetKey8(), ReadKeys8() and GetKeys8() are the
8-key mode's. Key numbers are 0 for none, and with several keys the highest wins.
The Arduino Library Manager's library named "TTP229" is for a different board, the I2C TTP229-LSF. It does not talk to this keypad.
What it does not model
Sensitivity (a pad either feels a finger or it does not), the 4 s recalibration
while no key is touched, the sleep mode's slower wake-up sampling (TP5, TP6), the
maximum key-on time (TP7, about 80 s, off as shipped), open-drain direct outputs
(TP0), and the sheet's two mixed single and multi-key group modes.
Common mistakes
Calling ReadKey16() with TP2 open. The chip sends only 8 bits, so keys 9 to 16
never come back: set keys to 16, or use ReadKey8().
Expecting one print per touch. A held key is reported every scan, so a sketch that
prints whatever ReadKey16() returns prints the same key about 30 times a second.
Print it when it changes.
See it in action
Touch keys prints the key you touch on an Uno. Open it at /templates.