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