i'm not going to detail the physical construction of the turret, i literally bolted one servo onto the other then nailed a piece of folded cardboard to it to hold the laser. the laser and servos all require +5v power supply so they're connected to the +5v pin of the arduino via the breadboard. the laser is connected to digital pin 12.

the servos require analog inputs; the rotation servo is connected to analog pin a0 and the up/down servo is in a1.

and that's the hardware set up!

for whatever reason people don't like python 3.x, so there aren't a lot of packages or forum support for it. for this project i *needed* pygame, which will only work on python 2.x, so that's what i'm switching too.

pygame [obviously] provides all the useful functions for making games with python, like mouse input and events, these are the features i need for real-time control of stuff. pygame makes controlling this turret effortless, here is the code:

the pygame inputs only work while the cursor is in the pygame window, so i made it nice and large.

this system is still very limited, when i refine it more i'll make sure the cursor starts in the center and it would be a good idea to make the height/width of the window correspond to the 180 degrees of servo motion [the system now just moves the servo when the mouse moves].