PWM in VB 6.0

Discussion in 'Programmer's Corner' started by Tessel23, May 14, 2009.

  1. Tessel23

    Thread Starter New Member

    May 14, 2009

    Greeeetss from holland
    Last edited: May 29, 2009
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    There is more to it than just some code. The LED is a current operated device, and will burn up (and quite possibly take your serial port with it) if current through the LED is not properly controlled.

    You have no indication about how you are planning to attach the LED to the port, so worrying about code fragments is getting ahead of yourself.

    I might suggest you read and understand our material on LED's -

    You also need to find what voltages are present out of the COM port, so you can arrange for a properly-sized resistor to control current in the LED. Then you can see about generating code to control the LED with PWM.

    Do you have any idea what that code fragment is supposed to do?

    Senior Member

    Jul 1, 2008
    You're going to need a current limiting resistor for the LED. A 2.2k LED limiting resistor should be a fair ballpark value for a start. Your code needs help though. As it currently stands, your code will throw as many design time and run time errors as you have lines of code! You may also want to consider utilizing the DTR pin instead of the TX pin, as the code to do this will be easier.
  4. Tessel23

    Thread Starter New Member

    May 14, 2009
    Ty for ur help