I want to use the gpio pins on the pi too use it as a mouse for a PC. Can it be done? If yes then how? I want to use python.
Why not using a Pi Zero (W), which can operate in the so-called USB gadget mode? The Pi Zero (W) then appears as a normal USB mouse/keyboard to the PC. Please note that this isn't possible with a Pi A/B, but only with the Zero Pis. Using USB gadget mode avoids having to emulate serial mouse, unless you have a really old PC system which hasn't USB support.