Switch between automatic and rc

I'm new to programming is there a way to switch between automatic driving and remote control on a 2 motor rc car with a switch or maybe another method

Yes

Please post your current code