Hi, hope this is the right subforum for an introductory query. First timer, attempted search and found very conflicting answers. I know the Leonardo is old and out of current support, too, so willing to go with a different board if I must.
I have a 'sim-pit' (simulation cockpit) for spaceflight games, pic link below if anyone's curious. The chair is configured with multiple USB peripherals (joystick, auxiliary touchscreen monitor, etc), and want to use an Arduino Leonardo in HID mode as an additional button-box (momentary buttons, some latching, and an encoder). I think I have a handle on how to program all that, pretty basic with plenty of examples all over.
Issue is that after programming, I want to leave the Arduino plugged in to the computer's USB (via a powered hub in my chair base structure), but only have the computer see it as "on" when I enable the external power thru the barrel connector to the Leonardo directly (e.g. turn "on" the button box with a switch). The chair has a 12VDC/30A PSU in it that supplies power to the seat motors, USB hub, fans, etc. and I will have switchable power distribution to specific items.
From what I read the Leonardo auto-selects source of power from USB or the external connection, or both, with the 12V enough it won't really "use" the USB power if external power is there, but as it will be plugged into a powered hub I need to break that option somehow. If it receives power from USB it is 'on' anytime the hub is (whether or not the computer is even on). So to force it to only receive power from external, I can either
cut the voltage line in the USB cable
remove the polyfuse
remove the T1 (?) FET
I read however that if I were to turn off external power (shutting down the Leonardo) in some of those cases, with non-powered USB still physically connected, and turn the power back on again, the W10 computer might not recognize "a USB device is newly active" and re-connect it.
Is there a right way to make sure that the Leonardo on power-on "behaves" as if it was just plugged in to USB anew each time? I did read about setting the COM port to 1200 as a way to trigger a reset which would include the communications, but seems like if I put that in my sketch up front I might be just putting myself in a loop, unless the sketch can test and only do that reset on need?
So to summarize the behavior when deployed that I want is:
- USB always plugged in, assume computer is on and Leonardo power 'off' to start
- Turn Leonardo external power on, computer sees it as HID device
- Turn Leonardo external power off, computer no longer sees it because it's off
- Turn Leonardo external power on, computer again sees it as a connected USB device...
- (rinse and repeat)
Overall chair pic link for the interested: Simpit Sitrep, August 2019 - Album on Imgur