Capacitive touch or accelerometer for switching patterns

I know that a button can be added to the PB to provide a means of switching the patterns, and I think I saw that there is no means for switching within the software (except for the possibility of switching between multiple patterns with a pattern). But I wonder if it would be possible to use a capacitive touch sensor, or the accelerometer, to instigate a switch between patterns if you connected a digital output to the button input. For example, connect GPIO4 to the button input, set GPIO4 high in the code, and then monitor for a capacitive touch on another input. When a touch is detected, set GPIO4 to low for 0.5 sec to generate a switch. (Obviously, the appropriate code would need to be in the beforeRender code of each pattern.)
Would that work? And if so, would a resistor be required between GPIO4 and the button input? Could you ALSO have a button between ground and the button input, to allow for wifi resets?

Right, any input could be used within a pattern: a GPIO doing touchRead(pin), GPIO doing a digitalRead(pin), readAdc(), or anything from the sensor expansion board, or even an exported variable being changed over the network.

You could drive the button via GPIO, putting it low and in OUTPUT mode, then switching back to INPUT mode after a short period of time, as long as you are careful not to hold it low for too long (triggering setup mode) and not to drive it high or risk creating a short when the button is pressed.

There’s no API to programmatically load other programs yet, but I’m definitely considering it!

Thanks, Ben! To clarify, in your statement:

are you suggesting that I don’t need to have a physical connection between the button input and a GPIO output? In other words, can I just drive the button GPIO itself to low?
Apologies if my questions have obvious answers. I’m kind of new to all of this, but I’m having a blast learning.

I wasn’t, but now that you thought of it and mention it, yeah, I think that would work.

It’s a little dangerous though, in that it would be hard to undo if you wrote a pattern that put it into setup mode accidentally. If you used another gpio, at least you could disconnect them if something went wrong and recover things.

Good point about the possibility of endless resets if done through code only!
I tried it with a jumper between GP4 and the button input, and it worked flawlessly. Thanks!