2
\$\begingroup\$

Is it possible to control output from a computer usb port so, for instance if I have a usb led I can make it blink or do whatever with it. Whenever I send a high signal it would glow and whenever I send a low signal it would turn off. Is it possible?

NOTE: I don't know if it is the appropriate site for this question. So, tell me where to ask if not from here.

\$\endgroup\$
2
  • \$\begingroup\$ Some but not all motherboards support to power on/off individual USB ports. The required operating support however has either never existed (I believe Windows) or has been removed from the kernel (Linux). In other words, you'll need some extra hardware to control your LED. For a beginner's level electronics and programming, you might like to search for 'Arduino'. \$\endgroup\$
    – jippie
    Apr 23, 2015 at 6:24
  • \$\begingroup\$ Thanks I know about these little computers there is Arduino, Raspberry pi and a few others! Thanks @jippie \$\endgroup\$
    – Anonymous
    Apr 23, 2015 at 6:27

3 Answers 3

5
\$\begingroup\$

USB is a communication protocol. When I say its a protocol, it means that there are certain rules that you have to follow in order for your computer to communicate with the targeted device.Bellow is the wire structure required for USB communication. enter image description here

Now, by default, your USB power supply is always on. But there are few computer motherboards that provides you to turn on or off depending on your need. If you just want to control a single led (turn on or off) then you would want to check weather this facility is available with your motherboard.

If you don't have, then the solution becomes a bit difficult. This is because you can not control the voltage levels of DATA- and DATA+. Thus you might have to create a device that would understand and decode a USB packet. So when you send the turn on or off signal encapsulated in a USB packet, the device would understand your command and control the led for you.

for the second option, check out Arduino. There are very good examples for you to work on for arduino. These boards make use of FTDI chips that @MarkU suggested.

\$\endgroup\$
0
2
\$\begingroup\$

USB ports use a more complicated protocol than GPIO (or the old PC parallel printer port). You can't just directly connect a GPIO (like an LED) and toggle it.

The simplest way to use USB is to connect an FTDIchip.com FT232; these are very low-cost and readily available both as bare chips and as assembled modules, and the device driver is already installed on most modern operating systems. Then you can open the port using FT_Open() and configure the chip for "bitbang mode". This gives 8 pins of GPIO that can be driven by any USB port.

There are other ways too, but they always involve using a USB Serial Interface Engine, either inside the chip (like FT232) or in an IP core (like in an FPGA). The details of the protocol can be found in the USB specification, at usb.org.

\$\endgroup\$
0
0
\$\begingroup\$

There are hubs that can turn ports on and off programmatically using C++ or Python. Check out the Acroname USBHub2x4 and USBHub3+. We use these in our regression test setup and love the APIs.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.