How does the mouse work

As you move the mouse over a surface, the ball or sensor moves the rollers that are in contact with it. One roller is responsible for the lateral movements and another for the vertical ones. The rollers are connected to wheels, called encoders, which are located in front of small light emitters. These wheels have grooves that allow light to pass through to photosensitive devices that detect flashes and translate them into coded information that the computer is capable of interpreting. On the other hand, when a mouse button is pressed, another type of signal is generated, which the computer will distinguish from the previous one and which, depending on the program being used, will allow different operations to be carried out.
When this moves, the movement of the ball that is in its lower part breaks down into two movements according to two wheels with axes perpendicular to each other (corresponding to two axes of coordinates X and Y) that an analog-digital converter translates into electrical pulses . The number of pulses generated for each axis represents the distance traveled by the ball with respect to that axis represents the distance traveled by the ball with respect to that axis, and in relation to the last position in which the mouse was still. These pulses are counted in two counters, one for each axis, and can be counted progressively or regressively, depending on the direction of the mouse movement with respect to said axes. The circuits send through a cable that goes to a serial port of the computer-the value of the count of the counters, as two signed 8-bit numbers (range -128 to +127). According to the MICROSOFT protocol, these numbers are sent as part of bytes, each of which is also transmitted START and STOP bit according to the RS 232C protocol for a serial port.
Three bytes are sent when a mouse key is pressed or released, even if the mouse is not moving. When the port receives the first of the three bytes, the board with the buffer interface, which contains the circuit of said port, requests the CPU to interrupt the running program and proceed to execute the subroutine (Mouse driver) that handles the information of the port. Mouse.
If you hold the mouse in your hand and look at the bottom of the mouse, you will see that some have a scroll ball or just a red light. These sensors are what allow you to move the mouse on the table or mouse pad to direct the mouse pointer to the position you want. To move the mouse, gently place your hand on the mouse (as shown in the photos) and move it slowly on the table or mouse pad. You will notice that the pointer also moves as you move the mouse.