The Code

Capacitive Touch


For the capacitive sensor, before we start the code, we need to set our threshold. This determines the sensitivity of the input sensor. This needs to be done only once, so you can put it in the “on start” block.

Now, in an If statement, you can simply check if each capacitive sensor has been triggered by checking if the pin has been pressed. Depending on the threshold you can even tigger a capacitive sensor by being close to it and without having to actually touch it. You can also sense touch through thin materials like paper. Capacitive sensing works best to detect fingers.