Look up these topics: PID - guide Statemachines - example
You can find many VEX programs on github or on the forum for examples.
An extreme example of drivercontrol automation is in our Turning Point showcase, under “Angling Hood”: