Detecting touch without having a button has become very common in the past few years. The technology is found on refrigerators, microwave ovens, and TVs. It is also similar to how touch screens work on phones and tablets.

Touch sensing relies on measuring a very small capacitance found on a pin. When a pin is touched by a finger, the capacitance is changed and a touch is detected. This is why this is sometimes called capacitive touch sensing.


For capacitive touch to work properly, a specific circuit needs to be added. This circuit is made available on all large pads on the BrainPad. An alligator clip is all we need, but that clip can then be connected to any object to detect, like a banana!

The second argument in Touch() is to calibrate the sensing level. Each wire, circuit, and body will differ when it comes to resulting capacitance. The level argument helps in changing the level of sensitivity. It ranges from 0 to 100, and 50 should work in most cases.

This code will detect and print touch twice every second.

var captouch = Touch(P0, 50);

captouch = Touch(P0, 50)

while True: