2 LEDs and one pin left


Closed Thread
Results 1 to 40 of 54

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    1,0
    0,1
    0,0

    LEDs on these states won't be possible by one pin.
    Instead, use 4017 with one pin.

    I have an example here:
    http://www.picbasic.co.uk/forum/showthread.php?t=6548&
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Jumper,

    You can use "one LED" only like the one in the link below. This is pretty much two LEDs put together. It is a red-green 3mm LED.

    http://futurlec.com/LED/LED3RG.shtml

    Quote Originally Posted by sayzer View Post
    1,0
    0,1
    0,0

    LEDs on these states won't be possible by one pin.
    Instead, use 4017 with one pin.

    I have an example here:
    http://www.picbasic.co.uk/forum/showthread.php?t=6548&
    However, the bad news is that Sayzer is right. You can't get three states "0,0", "0,1", and "1,0" with only one MCU pin.

    Robert

  3. #3
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rsocor01 View Post

    However, the bad news is that Sayzer is right. You can't get three states "0,0", "0,1", and "1,0" with only one MCU pin.
    Really? Because I am using Dave's code on a 18F26J50 (3.3 volt) with no resistors, and it works like a charm. Red, Blue, off
    Name:  dual-led3-3.PNG
Views: 2465
Size:  13.9 KB
    Code:
    BLINK:  
         HIGH PORTA.0 
         PAUSE 250 
         LOW PORTA.0  
         PAUSE 250   
         TRISA.0 = 1 
         PAUSE 2000    
         GOTO BLINK
    Last edited by ScaleRobotics; - 13th July 2010 at 22:48.

  4. #4
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    Really? Because I am using Dave's code on a 18F26J50 (3.3 volt) with no resistors, and it works like a charm. Red, Blue, off

    Code:
    BLINK:  
         HIGH PORTA.0 
         PAUSE 2500 
         LOW PORTA.0  
         PAUSE 2500   
         TRISA.0 = 1 
         PAUSE 20000    
         GOTO BLINK
    DOH,

    The trick is in the TRISA.0 = 1 to get both off (the 0,0 state). Nice!

    Robert

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I think this page explains what Walter is doing pretty well ...
    http://www.batsocks.co.uk/readme/p_tut_led16.htm
    DT

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Simplest coding would be to generate a square wave signal on the pin, and then set the TRIS based on state of each LED. TRIS would have to be set every time you change the state of the pin in the square wave generating code. That way the LEDs will always be the same brightness. Of course the square wave signal would have to be interrupt driven off of a timer in order to have both LEDs on at the same time.
    Tim Barr

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    Really? Because I am using Dave's code on a 18F26J50 (3.3 volt) with no resistors, and it works like a charm. Red, Blue, off
    Attachment 4604
    Code:
    BLINK:  
         HIGH PORTA.0 
         PAUSE 250 
         LOW PORTA.0  
         PAUSE 250   
         TRISA.0 = 1 
         PAUSE 2000    
         GOTO BLINK
    Nice trick indeed.
    How about RED and BLUE = ON ?

    (without ".....Of course the square wave signal would have to be interrupt driven off of a timer in order to have both LEDs on at the same time. " )
    Last edited by sayzer; - 16th July 2010 at 12:24. Reason: typo
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  8. #8
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    Nice trick indeed.
    How about RED and BLUE = ON ?

    (without ".....Of course the square wave signal would have to be interrupt driven off of a timer in order to have both LEDs on at the same time. " )
    Nice one Sayzer! I guess that is four states for one pin!

  9. #9
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    Nice one Sayzer! I guess that is four states for one pin!
    Yes, the four states can be obtaind with only one pin. Very nice!

    Now, if you use the red-green LED that I mentioned above a cool project can be made.

    http://futurlec.com/LED/LED3RG.shtml

    Since red + green = yellow, then with only one pin in the MCU we can obtain four different states in the LED: off, red, green, or yellow. Also, by varying the percentage duty cycle of the square wave different shades of yellow can be obtained. I haven't tried this yet but it might be a cool project.

    Robert

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


    Did you find this post helpful? Yes | No

    Talking

    RED and BLUE = ON

    The only way I can think of is to connect them in parallel. (if serial, 3.3V will not go through)
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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