Arduino Uno Mouse [Serial.write()]

Good Day All,

My question is basically about the Serial.write() function. I have successfully created a USB HID mouse using the Arduino Uno R3 and have written a program to move the mouse in a square as soon as I plug in the Uno in any PC's USB port. The exact code I have written can be found here in this person's blog: Turning your Arduino Uno R3 into an USB mouse | Anh Nguyen

My problem is this : The mouse moves perfectly in a square but after some time, the mouse movement changes it's path. To make it more clear, from the code itself the mouse should move in a particular given path, it is not supposed to deviate from the original square path but in this case, though the mouse continues to move in a square, the square paths are made at various parts of the screen.

My take on this: According to me, the problem lies in the Serial.write() function as shown in that program. I think it is not sending all the values properly which is why the mouse is deviating and making square paths at different places on the screen rather than staying at one fixed position. Now that I've guessed what the problem is (please correct me if I'm wrong), I'm not really sure how to fix this problem, I don't know why it's behaving like that. If anyone has any suggestions regarding this matter, it would be highly appreciated.

Regards,
Swaraj

If you connect more than one mouse to a PC, both will move the mouse pointer.
Move one up and down and the other side to side, the pointer moves in circles.
So if your PC mouse makes even small input the square will move.

please correct me if I'm wrong

Consider yourself corrected, then.

PaulS and GoForSmoke, that is not the answer!, the solution is to disable pointer precision in the control panel and then the mouse will be move in accordance to the signals sent by the Arduino, hope this helps the future readers with similar problems.

swarajdubey610:
PaulS and GoForSmoke, that is not the answer!, the solution is to disable pointer precision in the control panel and then the mouse will be move in accordance to the signals sent by the Arduino, hope this helps the future readers with similar problems.

So, you made a change to the mouse handler coconfiguration on the PC, and suddenly the Arduino was able to Serial.write() data properly? I don't think so!