Go Down

Topic: detect if USB is plugged in ? (Read 2213 times) previous topic - next topic

Dirk67

Dec 14, 2016, 04:43 pm Last Edit: Dec 14, 2016, 04:48 pm by Dirk67
MKRZero:
is it possible to detect from the processor (within my sketch),
if the USB is plugged in/or not ?
(regardless of serial communication / only detecting the presence of 5V VUSB ?)

(need it for MSD bootloader)
arduino powered car relais / car "micro PLC" / with USB --> http://goo.gl/ofWFW3

a_guadalupi

Hi, yes it is possible but isn't a built in-function.

What you can do is test if there are or not the 5V. This voltage is there only if the USB is plugged. So if you scale down this voltage (voltage divider) to 3.3V using digitalRead() if you have HIGH USB is plugged, otherwise not!

Hope this help ;)

Go Up