Powering an Arduino using a USB cable ?

Thread Starter

M3Dr

Joined Jul 6, 2021
4
Hello everyone, I hope you're doing well !
I have a project which consists in controlling a mouse using an arduino and I need it to be the most compact possible. So I thought of using the 5V of the USB port of the mouse to power the Arduino but I don't know if it is risky or not. Also, will the USB port still recognize the mouse, considering that it powers the Arduino or not ?
If you have any suggestions I will be glad to read them.

Thank you very much ;)
 

Thread Starter

M3Dr

Joined Jul 6, 2021
4
Hi ericgibbs, thanks for your answer, I wasn't sure it would be enough to power the arduino !
But I have a problem I expected : when I power the Arduino, the USB port is no longer recognized as a mouse... Perhaps I haven't wired it well and perhaps there is something to be careful not to do but I don't know what.
 

Deleted member 115935

Joined Dec 31, 1969
0

Thread Starter

M3Dr

Joined Jul 6, 2021
4
hi M3,
Do you have a diagram to post that shows how the Mouse and Arduino are interconnected.
Also is your project sharing the USB +/-D data lines in some way.??
E
Hi!
No I don't use the +/- data lines of the USB, but I found the solution to my problem : I forgot to add a diode to my circuit to protect the USB port :/ and I think the problem was coming from there as there might have been some of the power back to the USB port from the Arduino, so the mouse was not recognized.
Thanks for your answers and your involvement anyway it was really helpful ;)
 

Thread Starter

M3Dr

Joined Jul 6, 2021
4
To program the arduino, and communicate with it , the arduino uses by default its USB port, as a serial terminal,
and the arduino talks to the IDE on the PC.

If you want the arduino to now emulate a mouse,
the Arduino has to also run the the HID protocol the mouse uses..

https://www.arduino.cc/reference/en/language/functions/usb/mouse/

As ever. I will give plug to my favourite Arduino
that has great libraries for this

https://www.pjrc.com/teensy/
https://www.pjrc.com/teensy/usb_mouse.html
Hi Andrew,
In fact I still want the mouse to work but I want it to have the clicks controlled by the Arduino and my problem was that the USB port was not recognized as a mouse by my computer. But eventually I found the solution by simply adding a diode between the arduino and the +5V coming from the computer ;)

Thanks for your answer and you help, it may be useful for a next project !
M3Dr
 
Top