Controlling voltage supply on usb port using c or any programming language

cusb

I don't have much konwledge in electronics. i wanted to turn on/off led connected to usb port using program. usb port consists 4 line (data+,data-,voltage ,ground) if i connect voltage and ground lines to led , it will glow. i've been searching on internet this issue and i find that it is not possible to control led connected to usb using program because supply over datapin is too low which can not be used to tun on off led.

but what if i connect my led to vol and ground pin and control the entire power supply of usb port , i guess it is possible to control led using program. there is a way to disable and enable power supply over usb port.

i also want to know is it bad to follow this approach. does it damage usb controller to frequently enable/disable power supply.

Algo :

      a = Get_input_from_user() ;
      if(a=="ON")
           turn power supply of usb port ON.
          else
           turn power supply of usb port OFF.

this thing is certainly possible using extra hardwares, i don't want to use any extra hardware.

Best Answer

The power for a computer's USB ports is generally not software controllable. In most cases, the power pins of your USB ports are wired directly to the 5V rail of your power supply (usually through a polyfuse), so there is no way to switch them on and off.

Some powered USB hubs do support switching power to their ports, but you said that you didn't want to use any extra hardware, so you're out of luck.

Related Topic