A less Cumbersome way of manipulating several LEDS?


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Sorry, I misunderstood that. I thought you wanted one on when the other was off. I guess I kind of took that for granted because I can't really see the point in using more than one pin. Just wire the LEDs in parallel or, which is probably better, in series. Depends on the powersupply voltage and forward voltage drop of the particular LED.

    Are these some high power blue LEDs? High current and high Vf? Is that the reason you need one pin for each LED? Please tell me what I'm missing :-)

    /Henrik.

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Quote Originally Posted by HenrikOlsson View Post
    Sorry, I misunderstood that. I thought you wanted one on when the other was off. I guess I kind of took that for granted because I can't really see the point in using more than one pin. Just wire the LEDs in parallel or, which is probably better, in series. Depends on the powersupply voltage and forward voltage drop of the particular LED.

    Are these some high power blue LEDs? High current and high Vf? Is that the reason you need one pin for each LED? Please tell me what I'm missing :-)

    /Henrik.
    Yes, I'm using high brightness blue leds (fwd voltage 3.2V, my PSU is 4V) in parallel drawing about 20mA, therefore two = 40ma...too much for one PIC pin...hence wanting to treat two pins as one virtual pin in code. But it's no big deal....thought I'd ask - and as ever there is something that exists that can be brought into play, except that I need to control the pin on/off via TRISC to avoid clicking so I can't personally use it.
    Last edited by HankMcSpank; - 2nd September 2011 at 10:17.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Maybe something like this? Not very swanky, but should work.

    Code:
     
    LED VAR WORD
     
    Main:
    LED = %XXXXX111111111 'ALL LEDS ON 
    GOSUB LED_OUT
    LED = %XXXXX000000000 'ALL LEDS OFF
    GOSUB LED_OUT
     
    Goto Main
     
    LED_OUT:
    PORTC.6 = LED.0
    PORTB.6 = LED.1
    PORTB.5 = LED.2
    PORTB.4 = LED.3
    PORTC.2 = LED.4
    PORTC.1 = LED.5
    PORTC.0 = LED.6
    PORTA.2 = LED.7
    PORTA.1 = LED.8
    RETURN

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Since you are driving LEDs, why not MIBAM ?
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Quote Originally Posted by sayzer View Post
    Since you are driving LEDs, why not MIBAM ?
    I have a common dim function in place already (via a PWM driven mosfet)...I don't really need dimming per pin

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Hi Mark, Apologies...I missed your earlier contribution...that looks like something along the lines of what I need...I'll give it a try over the weekend - many thanks!

  7. #7
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    You probably realize this... but you will need a pause, of some time delay, after each "GOSUB LED_OUT", in Mark's example. In order for your eye to see the LED's ON or OFF or they may just appear to be flickering at half brighteness.

    Also the "X's" in the example will not compile... need to use "0's". At least they don't compile using microcodestudio.

    Code:
    LED VAR WORD
     
    Main:
    LED = %0000000111111111 'ALL LEDS ON 
    GOSUB LED_OUT
    PAUSE 500 'or delay of your choosing
    LED = %0000000000000000 'ALL LEDS OFF
    GOSUB LED_OUT
    PAUSE 1000 'or delay of your choosing
     
    Goto Main
     
    LED_OUT:
    PORTC.6 = LED.0
    PORTB.6 = LED.1
    PORTB.5 = LED.2
    PORTB.4 = LED.3
    PORTC.2 = LED.4
    PORTC.1 = LED.5
    PORTC.0 = LED.6
    PORTA.2 = LED.7
    PORTA.1 = LED.8
    RETURN
    good luck!!
    Last edited by Heckler; - 3rd September 2011 at 00:31.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts