2 LEDs and one pin left


Closed Thread
Results 1 to 40 of 54

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    China
    Posts
    266

    Default 2 LEDs and one pin left

    Hi All,

    I have one red LED and one GREEN led and a few resistors and only ONE pin left on my MCU. It would be nice if there is a way to turn on green or red or have them both off.

    Since the pin has 3 states it might be possible but today my brain just can't see how. Current goes in .. one LED is on... Current goes out.. the other one is on. But it is possible to have them both turned off without haveing any leaking current when the pin is in tri-state?

    I never plan to have them on at the same time... just both off or one or the other on.

    thanks!

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Output HIGH
    Output LOW
    Input

    Maybe
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default doh

    and what makes the current not flow thru any of them when the pin is in INPUT?

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    From a data sheet.
    Setting a
    TRISA bit (= 1) will make the corresponding PORTA pin
    an input (i.e., put the corresponding output driver in a
    Hi-Impedance mode)
    http://en.wikipedia.org/wiki/High_impedance
    Dave
    Always wear safety glasses while programming.

  5. #5
    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

  6. #6
    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

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


    Did you find this post helpful? Yes | No

    Default

    Can't you?
    Name:  dual-led.png
Views: 2345
Size:  9.4 KB

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    My turn to say DOH!!!

    No matter how you connect two LEDs without extra hardware there will be feed back between the two.

    A couple transistors or sayzer's solution are in order for this one.
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    How many DOHs are allowed in one day???

    DUH code
    Code:
    BLINK:  
         HIGH PORTG.4 
         PAUSE 250 
         LOW PORTG.4  
         PAUSE 250   
         TRISG.4 = 1 
         PAUSE 2000    
         GOTO BLINK
    And
    Name:  LEDs.jpg
Views: 2316
Size:  15.4 KB
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default well

    Then we have the problem with the idle current.... 2 resistors in serie between Vdd and Vss is going to drain the battery. I like the idea! but the idle current will be almost half of what the LED uses when it is turned on (sssuming 5V Vdd and 2V voltagedrop over the led)

    I dont have my lab stuff here.. does anyone think the idle current might be lower in the circuit i have attached.. or will smoke come out :-)

    Sure there are many ways to solve the problem by adding more things but I am still hoping this will work...

    or it will be DOOH and an other design.

    Thank you!
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    Square wave sounds more difficult than Dave's code, and any square wave will light up both LED's on a two led with 1 output scenario. And Jumper just wants one, or none to light at a time.
    Last edited by ScaleRobotics; - 14th July 2010 at 17:52.

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