Shop OBEX P1 Docs P2 Docs Learn Events
pwm for leds — Parallax Forums

pwm for leds

rrrr Posts: 63
edited 2005-04-15 04:15 in BASIC Stamp
does anyone have any sample code for controling led brightness with pwm or know where i can get more info??? also is it going to be possible to control multipul led circuits at the same time with pwm??? for example i would like to be able to have one cicuit of leds getting dimmer as another circuit of leds is getting brighter. i know the bs2 cannot do multipul tasks at the exact same time but can the code be layered to seem like it is??? thanks for all the help...

Comments

  • OrionOrion Posts: 236
    edited 2005-04-14 15:59
    You won't be able to control the leds like your thinking. As soon as one pwm command stops the current set of leds will go out and the next set will light. Look for a pwm IC like http://www.awce.com/pak5.htm. It's easy to use and will do what you want.

    BTW -·I have code for a bs2 that controls the pak5.· I used it with tri-colored leds. As one color dims the next brightens, and so on.· Let me know if you want it.

    Post Edited (Orion) : 4/15/2005 12:46:38 AM GMT
  • rrrr Posts: 63
    edited 2005-04-15 01:07
    will you please post the code that you are talking about... also will the pak 5 be able to control many leds through a transistor(see below)???
  • rrrr Posts: 63
    edited 2005-04-15 01:16
    sorry the image is not showing ill try again
  • rrrr Posts: 63
    edited 2005-04-15 01:17
    i guess i am having problems heres the link to the image

    http://forums.parallax.com/attachment.php?attachmentid=37573
  • OrionOrion Posts: 236
    edited 2005-04-15 02:24
    Code is for a bs2 using a pak5 to fade between the first three outputs.· The circuit above hooked to the pak5 should work is pretty similar to what·I used.· The bs2 alone will drive that circuit above, but as you have probably found it will only drive one pwm output at a time.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-04-15 04:15
    The way you are thinking of PWM is to have it drive the LEDs directly, and for that the Stamp can only do one at a time. That is the way the transistor circuit works in your link, http://forums.parallax.com/attachment.php?attachmentid=37573.

    However, there is another way to use the Stamp PWM in linear mode that will let you drive more than one circuit. The PWM value is stored on a capacitor, and an op-amp buffer that. Don't let op-amps scare you. You can get 4 op amps in one 14 pin dip package (LM324). The attached diagram shows one way PWM can be converted to current to drive an LED.

    For a program with different leds at different brightness levels, you would have several of these circuits. The Stamp program would move around a loop, refreshing and updating the PWM value for each LED in turn. The capacitors hold the value instructed until the next time the program comes around the loop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
    319 x 164 - 1K
Sign In or Register to comment.