# Power going through the LED

I was trying out a program that would create police light alternating blinks. It works well with just a red and blue LED, but as I added more LED to the board, the next two LED appeared to be dimmer than the first set. Is this a programming issue where its telling how much power to go through the set? Or will I have to pull out the separate battery kit and add more power in order for it to all light up equally. I would like to do at least 5 sets of red/blue alternate. I am using an Uno board for this. I don't know how much more details you need inn order for you to help me, but I am willingly to give more.

Is this a programming issue where its telling how much power to go through the set?

No. All the software controls is whether current should flow. It does not control how much current flows. The hardware does that.

I don't know how much more details you need inn order for you to help me, but I am willingly to give more.

The kind of LED? The size of the current limiting resistor?

PaulS:
No. All the software controls is whether current should flow. It does not control how much current flows. The hardware does that.
The kind of LED? The size of the current limiting resistor?

LED 20 mA
Resistor: 220 ohm

The Arduino should be able to power 10 of them, then.

Perhaps it is your code.

What voltage are the LEDs?

Please post a diagram of your circuit.

(deleted)

This is the diagram I am using.

How have you connected the extra LEDs to the circuit ?

This is the diagram I am using.

That shows two resistors and two LEDs. As soon as you added more than that, you are no longer using that diagram.

Here is the diagram I drew up.

The blue LED is dimmer than the red when it runs.

You can not put leds in parallel. Each needs its own resistor.

You always need to take into account the max current per pin (40mA absolute max) and the max current through the ground and Vcc (200mA) of the microcontroller; numbers for the 328 in e.g.the Uno.

Okay, that fixed it. Thanks for the help on that.

Now moving onward toward the program. What it is doing now is Red, blue, red, blue then repeat. What I want it to do is have both red LED going off at the same time and then both blue. So Its Red then blue then red.

Here's the code for it:

// Project 1 - Police Lights by Dave1324

int ledDelay = 50; // delay by 50ms
int redPin = 9;
int bluePin = 11;
int redPin2 = 8;
int bluePin2 = 10;

void setup() {
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(redPin2, OUTPUT);
pinMode(bluePin2, OUTPUT);

}

void loop() {

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

delay(100); // delay midpoint by 100ms

digitalWrite(bluePin, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

delay(100); // delay midpoint by 100ms

digitalWrite(redPin2, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin2, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

digitalWrite(redPin2, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin2, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

digitalWrite(redPin2, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin2, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

delay(100); // delay midpoint by 100ms

digitalWrite(bluePin2, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin2, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin2, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin2, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin2, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin2, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

}

I suggest that you read up on e.g. for-loops first. Repeating code can be placed ina for-loop or a while-loop.

Now loop() itself is called in a loop so you actually don't need to repeat code.

void loop()
{
Red1 on
Red2 on
Wait
Red1 off
Red2 off
Wait
Blue1 on
Blue2 on
Wait
Blue1 off
Blue2 off
Wait
}