I have seen these builds in the past. This is nice one if you are into paintball (you could put it in a defensive spot). It uses an arduino for the motor control and a webcam to target/detect movement. There is reference to more up-to-date instructions in the write-up, but the link is dead. 🙁
http://www.instructables.com/id/Autonomous-Paintball-Sentry-Gun/?ALLSTEPS