People have already done the hard work here, so start by reading what they built.
Two good references are www.rock-bots.com and www.paulridgway.co.uk/projects/gh3bot. Both document the hardware and software used to automate a guitar controller, which is far more useful than starting from a blank page.