Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. Controlling LEDs From USB port

Controlling LEDs From USB port

Scheduled Pinned Locked Moved Hardware & Devices
csharphelptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jonhbt
    wrote on last edited by
    #1

    I need to control a set of LEDs from a usb port. Can someone help or relate me to an article on how to do that please? I think I will try to use C# coding to access the usb port. Thanks

    L D M 4 Replies Last reply
    0
    • J jonhbt

      I need to control a set of LEDs from a usb port. Can someone help or relate me to an article on how to do that please? I think I will try to use C# coding to access the usb port. Thanks

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, 1. depends on how many LEDs. You could easily connect 3 to one serial port (e.g. a USB-to-RS232C cable); and use the SerialPort class to control the output control lines. 2. you could connect any number using external logic, basically implementing a shift register (needs data, clock, clear as a minimum; without an additional latch, they would flicker when a new data stream gets sent). This needs an external power supply. 3. you could connect any number supported by it by using a micro-controller. This too needs an external power supply. 4. yes C# can be used for such things. 5. have you googled? searched CodeProject articles? there are several. [EDIT] Of course you would need at least a series resistor to limit the current and keep things alive. Depending on the LED and the voltages of the serial port, I would go for 1000 to 4700 ohm. Lower = more current = brighter = more dangerous. Don't go anywhere under 470 ohm! [/EDIT] :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


      modified on Friday, August 14, 2009 10:11 AM

      1 Reply Last reply
      0
      • J jonhbt

        I need to control a set of LEDs from a usb port. Can someone help or relate me to an article on how to do that please? I think I will try to use C# coding to access the usb port. Thanks

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        You cannot attach an LED directly to the port and control it. There has to be an interface between the two. You can Google for "control LED USB[^]" for some example projects. You can also look at Phidgets.com for good interface kits, complete with drivers and an easy to use API.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008
        But no longer in 2009...

        1 Reply Last reply
        0
        • J jonhbt

          I need to control a set of LEDs from a usb port. Can someone help or relate me to an article on how to do that please? I think I will try to use C# coding to access the usb port. Thanks

          M Offline
          M Offline
          mustang86
          wrote on last edited by
          #4

          Hi. You asked the same question a year ago: http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&select=2672552&tid=2672552[^] My question is why do you want to "flash LEDs"? I doubt that your real desire is to have your PC light up an LED. :) So, it then comes down to what do you want to control with your PC, the reason, and so on. A super simple solution is the following: I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port[^] And an USB to Parallel adapter (~$15). http://www.amazon.com/Sabrent-SBT-UPPC-Parallel-6-Foot-Printer/dp/B0007UVRVO[^] But, if it's for something that going to be built and packaged, then that's different. In that case, your best bet could be to go with a USB bridge that has parallel outputs. You can use something like the Silicon Labs CP2103. Or, even the CP2102, and use the RS232 signals. https://www.silabs.com/products/mcu/Pages/CP2103EK.aspx[^] It's ~$30 for the test kit, and the chips are easy to get and very cheap. Also, FTDI makes a number of chips, like the FT245R. http://www.ftdichip.com/Products/FT245R.htm[^] I've used the CP2103 a lot. It's awesome for a simple, cheap, small space solution to have an embedded controller or FPGA communicate to a PC. Now, I need something faster than ~1MBit transfer. So, I'm going to use an FTDI chip. Otherwise, there are other products/boards, like at Phidgets.com, that have relays on the board so that you can drive more current. _______________ Joe

          modified on Saturday, August 15, 2009 7:2

          1 Reply Last reply
          0
          • J jonhbt

            I need to control a set of LEDs from a usb port. Can someone help or relate me to an article on how to do that please? I think I will try to use C# coding to access the usb port. Thanks

            M Offline
            M Offline
            mustang86
            wrote on last edited by
            #5

            Hi. Since it seems like this type of questions comes up every now and then. So, here's a quick list of other resources to look at: For something to use in the lab, dataq is one of the main companies that businesses go to for low-cost/mid-range solutions. A very cheap whay to get a few I/O pins and have it in a packaged form is: DI-158 Starter Kit Low-Cost USB Data Acquisition Device http://www.dataq.com/products/startkit/di158.htm[^] * Low-cost, compact, USB data acquisition starter kit. * Record data with 12 bits of measurement accuracy at rates up to 14,400 samples/second. WinDaq High Speed Acquisition software required for recording rates over 240Hz. * Convenient USB interface. * Four ±10V or optional ±64V fixed differential inputs. * Four digital bits for general purpose I/O. * Two 0V to 1.25V digital to analog output ports. Another pre-built board to consider is: http://www.xdimax.com/sub20/sub20.html[^] SUB-20 Multi Interface USB Adapter USB to I2C, SPI, GPIO, RS232, RS485, Ir, LCD * Full Interface Crosspoint - converts any to any * USB to I2C Master and I2C Slave, USB to SMBus * Up to 8MHz USB to SPI Master and SPI Slave * USB to GPIO - 32 GPIO, PWM Outputs * USB to ADC - 8 Analog Inputs (A/D Converters) * USB to RS232, USB to RS485, USB to ModBus * USB to IR (USB to Infrared) Adapter * 8x2 LCD, Leds, Push Buttons * Field upgradable and customizable * NI LabVIEW Support If this is for an end product or for a board, and you want to use Ethernet for connectivity, then Lantronix has a number of good solutions: Good solution for a board: XChip Direct SoC http://www.lantronix.com/device-networking/embedded-device-servers/xchip.html[^] Embedded Device Gateway SoC Co-Processor XChip * Connects to host microcontroller for serial to Ethernet (LAN) applications * Robust networking and applications firmware included – no coding required; zero royalty licensing agreement * Integrated 10-100 MAC/PHY; 256K SRAM; up to 230 Kbps data rate * Compact 12mm x

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups