2 LEDs and one pin left


Closed Thread
Results 1 to 40 of 54

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Add a bit of code and schematic for basic use....
    Ok.

    I attached the schematics to this post. The code is pretty simple. It uses only one pin in the PIC to create four states in the red-green LED. You can get Red, Green, Yellow, or the Off state in the LED using only one pin. Of course, for getting the last state (Off) all the credit goes to mackrackit. He figured that one out .

    Code:
    START:
    
    HIGH PORTB.0                 'Turn on red light
    PAUSE 2000 
    
    LOW PORTB.0                  'Turn on green light  
    PAUSE 2000   
    
    FOR I = 1 TO 2000            'Obtain a yellow light
       TOGGLE PORTB.0
       PAUSE 1
    NEXT I
    
    TRISB.0 = 1                  'Turn off LED
    PAUSE 2000 
       
    GOTO START
    Name:  LED-Schem.jpg
Views: 2678
Size:  14.1 KB

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    I vote for Muddy0409's except, I would put a resistor in series with the processor output lead to limit the output current. This is exactly what I would have proposed except I would have used a couple of zeners instead of the extra led in each leg... If you have an extra inverter available you could modulate one side of a bidirectional led (red/green) and connect the other side thru a resistor to the processor output pin and then place it either high or low and finally to an input state to shut it off.....

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Referring to the attachment 2 posts above,

    Am I just missing something? by my calcs, assuming 2V drop for the LED's the current would be 3/10000 = .3mA.

    Will this be enough to light the LED? By my calcs, I would think 150-200 ohms would be more suitable. Any help to clear this up for me?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    I don't think the attachment 2 posts above will do any good with 10k resistors.

    I had actually started making a flash demo for this when it first started, but with so many options it got too complicated.
    I really think the correct theory is in the link from post #13 though. The link is also in the flash below ... under the title. (batsocks.co.uk/ ....)

    I only made it through simulating +5V. Things are clickable in the image below ... try it.
    At +5V the resistor is 100 ohms (with 2 diodes).
    But if your situation is different, perhaps I can add to it. ...

    <OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="723" HEIGHT="800" ><PARAM NAME="MOVIE" VALUE="http://www.pbpgroup.com/files/2LED/2LEDS_1PIN.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="truSe"><PARAM NAME="QUALITY" VALUE="high"><EMBED SRC="http://www.pbpgroup.com/files/2LED/2LEDS_1PIN.swf" WIDTH="723" HEIGHT="800" PLAY="true" LOOP="true" WMODE="opaque" QUALITY="high" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>
    Oh, it says I attached the .dsn file ... I didn't, cause it wasn't done.
    But if you have Proteus, I will make it work for all conditions ...
    DT

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Wow!!

    Thanks Darrel. That is an awesome gadget. Is there any way to get you to replace d2 and d3 with variable resistors (or fixed if need be) and bypass the 200 ohm on the pin? This way it will be closer to the other circuit. I would love to test it (and yes, I am trying to use your sim instead of my breadboard) I think a more approiate value would be 0-1000 ohms. If not, its all good.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    Well, the problem with that ... is that the variable resistors would only control current.
    But the correct operation of the LED's depends on the voltage.

    If the total forward voltage of the LED's is less than VDD, both LED's will be ON no matter what the resistor values are. The only difference will be their brightness.

    Given a specific VDD voltage, LED color (V forward) and foward current, the correct configuration can be found.

    And to add 2 variable resistors to the flash demo, would increase the frames from ~50 to more than 500,000. I'm affraid that will take a few years to create, and you probably won't wait the 2 weeks to download it.
    I suppose it could be done more efficiently.

    But again, if you have Proteus, it's a "Piece of Cake".
    DT

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    thanks darrel, once again, it seems a case of I know not what I ask. Don't worry about the demo then. As for the actual circuit, I will have to mull over why the 2 resistors in series with the led's doesn't create a voltage divider.

    I would just LOVE to have proteus. I tried looking it up 1 time, seems it was in the 4 digits, just a little much for me
    Last edited by cncmachineguy; - 9th November 2010 at 04:59.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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


    Did you find this post helpful? Yes | No

    Default

    Actually, I'd rather know your conditions and do the math.
    What is it you need to do with your LED's?
    VDD, LED Forward Voltage / Forward Current?
    See if the theory works?

    Quote Originally Posted by cncmachineguy View Post
    ... As for the actual circuit, I will have to mull over why the 2 resistors in series with the led's doesn't create a voltage divider.
    Because the voltages across the resistors are changed by the voltage drops that are controlled by the LED's.

    I would just LOVE to haave proteus. I tried looking it up 1 time, seems it was in the triple digits, just a little much for me
    That's what I thought too at first.
    But they have a $250 "starter version" that gives you a 12F, 16F and an 18F.
    Of course it comes with all the other logic chips, analog stuff and test instruments.

    Even if it's not the exact chip you target, the "Family" is usually close enough to know your program has a chance.

    Beware:
    Once you get used to it ...
    You probably will spend $1000 for the full PIC version.
    DT

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