Using a TTP223 1-key capacitive touch module with MicroPython.
I was going to write a driver for this module, but it's pretty much just a drop in replacement for a push button. No driver needed.
The module features 3 pins, VCC, I/O and GND and has a red LED which illuminates when a touch is detected and the I/O pin goes HIGH.
It's sensitive enough to detect my finger around 3mm away from the touch pad.
Basic usage
from machine import Pin
import time
d3 = Pin('D3', Pin.IN, Pin.PULL_DOWN)
while True:
print(d3.value())
time.sleep_ms(100)
Using interrupts
from machine import Pin
d3 = Pin('D3', Pin.IN, Pin.PULL_DOWN)
d4 = Pin('D4', Pin.IN, Pin.PULL_DOWN)
def touch(pin):
print('Touched {}'.format(pin.name()))
d3.irq(touch, Pin.IRQ_FALLING)
d4.irq(touch, Pin.IRQ_FALLING)
There are 2 pads A and B which can be bridged with a dab of solder to change the trigger mode.
Pad A | Pad B | Description |
---|---|---|
Open | Open | Momentary, High TTL level output (default) |
Short | Open | Momentary, Low TTL level output |
Open | Short | Latching, High TTL level output |
Short | Short | Latching, Low TTL level output |
- VCC-GND STM32F407VET6 mini $15.47 AUD
- TTP223 Capacitive Touch Module $0.22 AUD
- Female-Female Dupont wires $0.64 AUD
STM32F407VET6 | TTP223 Capacitive Touch Module |
---|---|
3V3 (or 5V) | VCC |
D3 (any pin) | I/O |
GND | GND |
Licensed under the MIT License.