How to detect USB connection

Hello.
I'm using Arduino UNO R4 WIFI.
Serial.begin() takes about 10 seconds when USB is not connected, so I'm thinking of a solution.
Is there a way to detect USB connection before Serial.begin()?
Thank you.

Welcome! There is not enough information in your question to properly answer but I will take a SWAG. Assuming the UNO is the USB thing when it is connected its 5V goes active. Measure that and you should have it.

Thanks for the reply.
Sorry for my poor explanation.

When DC power is supplied without USB connected, Serial.begin() seems to take 10 seconds.
When USB is connected, Serial.begin() finishes immediately.

So I asked if it is possible to detect USB connection before Serial.begin().

You mean wire from arduino UNO's VUSB Test Point to the input, and receive HIGH when it is connected?

If you have a better solution, please let me know.
Thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.