Raspberry Pi Pico
Pimoroni touch:bit

The touch:bit is the micro:bit equivalent of the Raspberry Pi accessory called the Touch pHAT. Both are made by Pimoroni. They use a CAP1166 capacitive touch sensor to deliver 6 touch sensitive pads with LEDs. Apart from the connectors on these two accessories, the main difference is that the LEDs on the touch:bit are connected to correct pads. With the Touch pHAT, you need to do some work to make the LEDs light when you press the pads. Since you don't have to do that with the touch:bit, it is actually a little simpler to use with the Pico whilst still being a really cool input device to play with.

In the photograph, I have used the Pinbetween to hold the touch:bit. You need to connect the 3V and GND pins to power pins on the Pico. You also need to connect the I2C pins (19 SCL, 20 SDA) from the micro:bit to two of the many I2C pins of the Pico. I connected 19 to GP17 and 20 to GP16 for my test circuit.

Pico Circuit

Here is the library code I wrote and saved as touch.py.

from machine import Pin, I2C
from time import sleep_ms
from micropython import const

ADDRESS = const(0x2c)


class touchbit:
    def __init__(self, i2c):
        self.i2c = i2c
        self.i2c.writeto_mem(ADDRESS, 0x72, b'\x3f')
        sleep_ms(1)
        self.i2c.writeto_mem(ADDRESS, 0x41, b'\x30')
        sleep_ms(1)   
    
    def set_leds(self, led_byte):
        self.i2c.writeto(ADDRESS, bytes([0x74,led_byte]))
    
    def read_pads(self):
        self.i2c.writeto_mem(ADDRESS, 0 , b'\x00')
        data = self.i2c.readfrom_mem(ADDRESS, 0x03, 1)
        return data[0]

And here is some basic code to check that everything is working,

from machine import I2C, Pin
from touch import touchbit


i2c=I2C(0,sda=Pin(16), scl=Pin(17))
last = 0            
tbit = touchbit(i2c)
btns = ["<", "A", "B", "C", "D", ">"]
while True:
    reading = tbit.read_pads()
    if reading!=0 and reading!=last:
        bits = [reading >> i & 1 for i in range(5,-1,-1)][::-1]
        print(btns[bits.index(1)], "pressed.")
    last = reading