I am doing a project based on LED
I have 2 pins left. I need to control 3 LEDs.
The idea i have is to connect 2 LEDs parallel with opposite polarity to these pins and also from these pins take inputs of an AND gate and connect the 3rd LED across the AND gate output and ground.
THIS IS HOW I THINK THE ABOVE IDEA WILL WORK:::: for the first 2 LEDs output 01 or 10 to the pins and if i give 11 as output the 3rd will light up
220 - 330 ohms should be enough, and yes you should have a resistor (330 Ohms) for the 3rd LED. Assuming these are standard LEDs, that should be enough resistance.
Do you know what the LEDs drop voltages and the current rating (mA) are? I can give you a better answer with that information.
There are three main categories of miniature single die LEDs:
Low-current — typically rated for 2 mA at around 2 V (approximately 4 mW consumption).
Standard — 20 mA LEDs at around 2 V (approximately 40 mW) for red, orange, yellow, and green, and 20 mA at 4–5 V (approximately 100 mW) for blue, violet, and white.
Ultra-high-output — 20 mA at approximately 2 V or 4–5 V, designed for viewing in direct sunlight.
Five- and twelve-volt LEDs are ordinary miniature LEDs that incorporate a suitable series resistor for direct connection to a 5 V or 12 V supply.
So using this and an LED calculator, the resistance should be about 100-150 ohms, @ 5 volts.
Those resistor values should work fine. the 3rd led you can bring down a little, depending on how bright you want it.
yes, 2 pin only could drive 2 led with charliplexing. Anyway you could control 4 led with 2 pin with multiplexing,
A B LED1 LED2 LED3 LED4
0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0
With a multiplexer. The two MUX input pins are connected to the two available on the arduino. supply the voltage to the MUX and connect the LEDs with resistors to gnd.
LANE1 LANE2 LANE3 LANE4 time
green1 red2 red3 red 4 0
yellow1(2 sec) yellow2(2 sec) red 3 red 4 30 sec
red1 green2 red 3 red 4 32 sec
red1 yellow2 yellow 3 red 4 62 sec
red1 red 2 green 3 red 4 64 sec
red1 red 2 yellow 3 yellow 4 94 sec
red1 red 2 red 3 green 4 96 sec
LANE1 LANE2 LANE3 LANE4 time
green1 red2 red3 red 4 0
yellow1(2 sec) yellow2(2 sec) red 3 red 4 30 sec
red1 green2 red 3 red 4 32 sec
red1 yellow2 yellow 3 red 4 62 sec
red1 red 2 green 3 red 4 64 sec
red1 red 2 yellow 3 yellow 4 94 sec
red1 red 2 red 3 green 4 96 sec
Not going to lie, that is kinda confusing.
So you want a 30 sec delay between Grn and YEl, 2sec between Yel and Red and 30sec again between Red and Grn.
is that right?
no I want the green light to glow for 30 seconds. Then I want the yellow to glow for 2 seconds (Warning for a change from green to red).Then i need red to glow for 30 seconds.Then i want yellow to glow for 2 seconds (Warning for change from red to green)
What i have shown as a table is how a traffic light system at a 4 way junction will work.