Go Down

Topic: Arduino Uno Mouse [Serial.write()] (Read 62 times) previous topic - next topic


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: http://anhnguyen.me/2014/01/turn-arduino-uno-r3-into-a-mouse/

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.



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.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts


please correct me if I'm wrong
Consider yourself corrected, then.

The art of getting good answers lies in asking good questions.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131