locked
Turning on/off USB LED with VB .NET RRS feed

  • Question

  • I want to make a simple program with I can turn on/off litle USB LED.

    Nothing special, just one small LED as you learnt in 8th grade.

    I think the simpliest way to do this is "powering off" USB port. But how?

    I'm using Visual Basic 2008 Express Edition.

     

    Thanks.

    Wednesday, August 24, 2011 1:17 PM

Answers

All replies

  • You may try disabling usb-hub "temporarily" via devcon shell command using Process.Start with proper arguments, for suggestions, see these:

    http://www.codeguru.com/forum/showthread.php?t=410183

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272

    Otherwise, you'll need a .NET / or .NET-wrapper SDK of your USB-device to make it behave "as if" its LED is off.

    HTH.


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları VB.NET / C# Süper Moderatorü.

    Microsoft Haber Grupları Profilim (VB.NET)


    • Marked as answer by spajky1 Wednesday, August 31, 2011 8:58 AM
    Wednesday, August 24, 2011 1:56 PM
  • This can be accomplished (I think, but I'm not sure to remember well) via WMI API
    please, mark this as answer if it is THE answer
    ----------------
    Diego Cattaruzza
    Microsoft MVP - Visual Basic: Development
    blog: http://community.visual-basic.it/Diego
    web site: http://www.visual-basic.it
    Wednesday, August 24, 2011 2:07 PM
  • AFAIK, there is no satisfactory way to do this.  While you might be able to use DevCon, as another responder has suggested, this (IMO) is fraught with potential for disaster.

    The way that USB works is to attach a USB client device, to which you send commands.  The microcontroller that is embedded in this device responds to the command and does something "useful."  In your case, the simplest/least expensive adapter that I can think of is a USB serial adapter, which can be purchased for less than $10.  Connect your LED to the RTS output pin 9, in series with a blocking diode that will protect the LED against excessive back voltage when RTS is "low" (which may be as much as -12V).  You may also have to include a current limiting resistor, if the LED that you are using does not embed such.  Connect the other side of these components to Ground, pin 5.

    Then, you can use the SerialPort control from the toolbox to control RTS.  Simply Open the PortName associated with your adapter, and use SerialPort1.RTSEnable = True or False to control the LED.

    Dick


    Dick Grier. Author of Visual Basic Programmer's Guide to Serial Communications 4. See www.hardandsoftware.net.
    Wednesday, August 24, 2011 4:33 PM
  • @Dick:

    This would have been my exact suggestion as well... I can think of no other safe, reliable way to drive an LED directly off of a USB port wihtout a >$50 microcontroller in the middle.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
    Wednesday, August 24, 2011 7:52 PM
    Moderator
  • Devcon working for my PCI Wireless Card in my laptop...now the question is it gonna to work with LED beacuse there is all about power..Thanks and sorry for my bad english.
    Wednesday, August 31, 2011 9:00 AM
  • please, mark this as answer if it is THE answer

    Man I havent got internet connection in last few days - now its ok.

    Wednesday, August 31, 2011 9:03 AM