Shop OBEX P1 Docs P2 Docs Learn Events
LED Question — Parallax Forums

LED Question

NWCCTVNWCCTV Posts: 3,629
edited 2010-03-07 18:29 in BASIC Stamp
Is there any way, other than using different resistors to make an LED dim and then bright, such as with taillights/brake lights?

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2010-03-06 09:25
    Certainly. You turn it on and off very rapidly, so rapidly that it appears to be steady. The amount of time that it spends on compared to off determines how bright it appears.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-03-06 13:29
    Even easier -- you can use the PWM command for this effect.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-03-06 18:20
    Please explain. I am new to all of this. What I want to do is when my robot is moving, have a set of 2 red LED's that act as tail lights, then when the robot stops, these 2 LED's will brighten to give the effect that a brake pedal is being pressed.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-06 18:35
    You will have to figure out how bright you need your LEDs and what current is needed for the brightness you want. Each LED will need two I/O pins. This example below provides 5mA for an LED in one case and 10mA in the 2nd case:
    
    Vcc (+5V) -------->|-------- 680 Ohm -------- I/O pin 0
                                     |
                                     ---- 680 Ohm -------- I/O pin 1
    



    The ">|" is the LED with the anode connected to +5V. You use either a LOW 0 or a LOW 1 to turn on the LED on dim. You use a LOW 0 and a LOW 1 to turn on the LED on bright. The opposite of on is INPUT 0 and/or INPUT 1 which is the default. Don't use HIGH with the I/O pin. It won't hurt anything, but won't work.

    If you want the LEDs on dimly all the time while power is on, you can save an I/O pin by connecting one 680 Ohm resistor to ground (Vss) instead of an I/O pin. The other I/O pin will make the LED brighter when LOW.

    Post Edited (Mike Green) : 3/6/2010 6:42:47 PM GMT
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-03-06 18:55
    So in other words I would need 4 pins for just 2 LED's? That may cripple this idea, since I need several pins for this project. Thanks for the help everyone.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-03-06 18:59
    Mike, You confused me there. You say to use Low 0 and Low 1 to both turn LED's on bright and on dim. ????
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-06 19:06
    You use either LOW 0 or LOW 1 to turn the LED on dimly. You use both LOW 0 and LOW 1 to turn the LED on brightly.

    You can get by with only two I/O pins by using switching transistors or (as I described before) by keeping the LEDs on dimly all the time and using the I/O pins to make them bright. If you use switching transistors and keep the LEDs on dimly, you can get by with only one I/O pin.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-03-06 19:33
    Here's a circuit requiring only one I/O pin (see attachment.)
    580 x 408 - 99K
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-03-07 00:40
    Mike, Just so I do not burn anything out while trying your configuration, I need to supply VCC 5v from a seperate power source?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-07 00:45
    You don't need a separate +5V supply if your +5V source can handle the extra 10-20mA. If you're using a BoeBot with its own +5V 1A regulator, you'll be fine. If you're using the Stamp's built-in regulator (running the Stamp off 6-9V), you'll need to use some other +5V source for the LEDs.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-03-07 01:14
    Mike, I was able to get it to work using your example. However, I am getting a quick blink of the LED every 3 seconds. Should I use a different resistor or what?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-03-07 18:03
    see mod., attached,·for running LED from V_in
    580 x 408 - 33K
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-03-07 18:29
    The blinking probably occurs because your program ended or has gone to sleep. It blinks because the pin turns from output to input briefly at that interval.

    PAUSE 1000  ' LED off
    LOW 0         ' LED low
    PAUSE 1000
    LOW 1        ' LED bright
    PAUSE 1000
    END  <--- program ends, LED blinks at 2.5 second interval
    



    Use STOP at the end of the program to keep it active, or a simple DO:LOOP

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.