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 sayzer View Post
    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)
    No, that's not what I meant.

    If you apply a square wave to this red-green LED, the colors will change so quickly that it will look like it is yellow. I haven't tried it yet, but I'm pretty sure it will look yellow to your eyes.

    Robert
    Last edited by rsocor01; - 17th July 2010 at 12:51.

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


    Did you find this post helpful? Yes | No

    Default

    Hey Robert,
    Can you give some example code for how the square wave method would work?
    Say you have something like the sliding door app.
    Green = full open
    Red = closed
    OFF = inbetween
    Yellow = moving
    Dave
    Always wear safety glasses while programming.

  3. #3
    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
    Hey Robert,
    Can you give some example code for how the square wave method would work?
    Say you have something like the sliding door app.
    Green = full open
    Red = closed
    OFF = inbetween
    Yellow = moving
    Mackrackit,

    I'm going to order this part and test it to see if it works. The square wave is just a simple 50% duty cycle wave. By using the circuit provided by Scalerobotics, then if the square wave is low the red lights up and if the square wave is high then the green lights up.

    A rapid changing of colors red -> green -> red -> green -> .... would appear to be yellow. It is just an optical illusion. Remember that I talking about a red-green LED with both colors in the same LED casing. Still, I would need to test it to see if it works.

    Robert

    Name:  dual-led3-3.JPG
Views: 2192
Size:  90.2 KB

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


    Did you find this post helpful? Yes | No

    Default

    Looking forward to see your results, it would be very useful.
    Dave
    Always wear safety glasses while programming.

  5. #5
    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
    Looking forward to see your results, it would be very useful.
    Mackrackit,

    I tested this idea with a red-green 10 LED bargraph and yes it works. The setup is different from what we have been discussing in this thread, but the idea of getting a new color (yellow) is the same.

    First, I applied a square wave to the circuit with a period of 1.2 seconds and you can see how the color changes between red and green. Next, I applied a square wave with a period of 2 milliseconds per cycle (50% duty cycle) and all you see is a yellow color. Also, If you change the percentage of the duty cycle you get different tones of yellow. This would be very useful for a project like the sliding doors.

    Robert


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


    Did you find this post helpful? Yes | No

    Default

    COOOL!!!!!

    I can think of several places where that will come in handy.
    Looks like it would make a good article for the wiki. Add a bit of code and schematic for basic use....
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default 2 leds 1 pin

    Tried this on my Breadboard, works a treat.
    Hmmm....have to work out how to ad a JPG to this...
    BRB


    Ah, there it is, I hope. I know it means 2 extra LEDs, but that's gotta be cheaper than changing the PIC or messing around with the power supply.
    With the pin as an input, the 5 volt rail is not enough to turn on any of the leds, but setting the pin Hi or Lo the voltage is enough to turn on 2 of them. Also no current drawn during the Input stage.
    Attached Images Attached Images  
    Last edited by muddy0409; - 18th July 2010 at 10:39.
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  8. #8
    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: 2688
Size:  14.1 KB

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