Control a USB light via software
Solution 1
I'm going to use my PL-2303-based USB/serial bridge and an ATtiny2313 microcontroller running a USB stack--possibly USBtiny. It'll work like this:
- The USB light is attached directly to the microcontroller--not the computer
- An app/driver controls the microcontroller via USB
- The microcontroller sets the voltage for the USB light
I'll look into wiring it so there are some resistors on some outputs so I can set the light to different brightnesses, and if I want to do patterns or anything, I'll do them in software.
Solution 2
Your best bet is probably to buy something like an FTDI interface cable, available from Digi-Key for $20. That gives you +5, ground, and four wires you can switch high or low under software control. The software's easiest if you use the thing as a logic-level serial port with rx/tx/rts/cts. The manufacturer part number is TTL-232R-5V-WE (go to digikey.com and type that number into the part search box). Digi-Key has links to the manufacturer data sheets and web site.
Solution 3
I don't think it is possible, because the power (Vcc) line on USB is always-on--it is not intended to be a control line.
Unless your USB light already provides a way to control itself via USB data, you are out of luck. I do not recommend trying to change the voltage of the USB power line.
Solution 4
I guess this could be possible using the computer's ability to switch on/off the USB ports to save battery. After a surprissingly short search I found another question regarding that:
Controlling a USB power supply (on/off) with linux
Though I have not tried it. Please let us know if it worked!
![Justin Force](https://i.stack.imgur.com/6QK6L.jpg?s=256&g=1)
Comments
-
Justin Force about 2 years
I have a little USB-powered light. I'd like to be able to turn it on and off with software. I'll be attaching it to a Linux computer. I have an Atmel ATtiny2313 from a previous project, but I'd rather do this with a simple hack than repurpose my microcontroller.
Is this possible? I suspect this can't be done as the computer won't talk to a device without some kind of USB-compliant firmware?
I found this question, which has a comment suggesting that the OP use an LM317 voltage regulator to change the voltage of the USB out. I don't think this is applicable to me, but thought I'd mention it.
Update:
Looks like I could maybe put USBtiny on my microcontroller, then I could wire it up to the light, then I could write an app to control the controller. Sounds like a lot of work, though. I'd rather do a simple hack, but I lack experience with USB.
-
Justin Force almost 14 yearsBut can I manipulate the data output from the computer and use that as input to a transistor or microcontroller? Then I can control whether to let the 5V through to the light. I just don't know if I can manipulate the data pins on the USB port if the device on the other end isn't a legitimate USB device.
-
Hamish Grubijan almost 14 years+1 DigiKey is a damn good resource for serious electrical/computer engineering.
-
Justin Force almost 14 yearsThis looks cool. I think that my current USB/serial bridge may be able to help me here. I have a [PL-2303 ](prolific.com.tw/eng/products.asp?id=59) USB/serial adapter. Think that'll do it?
-
Justin Force almost 14 yearsI appreciate your suggestion and +1 it, but it doesn't really answer my question. Thanks for the DigiKey and FTDI tips, though! I especially appreciate the part number.
-
Patrick Szalapski almost 14 yearsSo you would shunt the data lines on the usb port to your own microcontroller? I suppose there is a way, but then you'd have to learn the USB hardware layer and how to write a driver for it.
-
Justin Force almost 14 yearsI considered this, but I doubt I'll be able to talk to the data wire of the USB port if the device at the other end isn't doing USB communication. I also know very little about USB. I think I'll know quite a bit by the end of this project, though. :)
-
Justin Force almost 14 yearsYeah! I think you're mostly right, but USBtiny should fit on my microcontroller, and should fill this role for me. I'm probably going to learn the USB hardware layer anyway for fun.
-
Admin over 8 yearsHow to do this in Windows 8, 10?
-
Patrick about 2 yearsYou can use, for example, PyFtdi to control the signals.