Ground a pin with a touch sensor?

Hi, I have a completed project that uses a normal push button switch that grounds one of the digital pins to complete a function. Is there a way to use a touch sensor to complete the same task without re-writing the code?

No experience with touch sensors.

A quick google revealed e.g. https://arduinogetstarted.com/tutorials/arduino-touch-sensor

From your description, your switch is currently wired between pin and GND; correct? So your pin is low when the button is pressed.

If so, you will need an inverter between the touch sensor and the pin because the touch sensor gives a high signal when touched. Else you'll have to rewrite your code.

sterretje:
From your description, your switch is currently wired between pin and GND; correct? So your pin is low when the button is pressed.

If so, you will need an inverter between the touch sensor and the pin because the touch sensor gives a high signal when touched.

The TTP223 has a selectable option for active HIGH or active LOW.