View Full Version : LED Question
03-06-2010, 03:42 PM
Is there any way, other than using different resistors to make an LED dim and then bright, such as with taillights/brake lights?
03-06-2010, 04:25 PM
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.
The Simple Servo Tester, a kit from Gadget Gangster. (http://www.gadgetgangster.com/206)
03-06-2010, 08:29 PM
Even easier -- you can use the PWM command for this effect.
03-07-2010, 01:20 AM
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.
03-07-2010, 01:35 AM
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
03-07-2010, 01:55 AM
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.
03-07-2010, 01:59 AM
Mike, You confused me there. You say to use Low 0 and Low 1 to both turn LED's on bright and on dim. ????
03-07-2010, 02:06 AM
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.
03-07-2010, 02:33 AM
Here's a circuit requiring only one I/O pin (see attachment.)
03-07-2010, 07:40 AM
Mike, Just so I do not burn anything out while trying your configuration, I need to supply VCC 5v from a seperate power source?
03-07-2010, 07:45 AM
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.
03-07-2010, 08:14 AM
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?
03-08-2010, 01:03 AM
see mod., attached,·for running LED from V_in
03-08-2010, 01:29 AM
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
LOW 1 ' LED bright
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