LED pin brightness issues

i am messing around with 8 LEDs. programing them in 2 groups of 4 to bounce, flash and general messing around... however no matter which pins i use the first group is full brightness and the second is much lower, reversing the groups/pins reverses which is brighter, but running the whole set off one set of 4 pins both are basically full ( as it should be) i can't find a reason for the brightness issues, all the same resistors all the same kind of LEDs
What might the issue be?
using a mega board with usb power

The chip can only provide 40 mA on each pin. How much power do your LED's require? If you don't know it's probably about 20 mA each so a set of 4 would be well over the limit for an I/O pin.

it’s one pin per LED group of 4 pins, i can change up the pins, fix the programming and the one group will still be brighter
at this point in time i have

int Leyeled[] = {22,23,24,25}; // choose the pin for the LED
int Reyeled[] = {26,27,28,29 };
int lpeye = 4; // the number of lights per group making the array

modified right out of the basics manual 

 one function is the basic weave

timer = 100;
int i;
for (i = 0; i < lpeye; i++) { // loop through each pin...
digitalWrite(Leyeled[i], HIGH); // turning it on,
digitalWrite(Reyeled[i], HIGH); // turning it on,
delay(timer); // pausing,
digitalWrite(Leyeled[i], LOW); // and turning it off.
digitalWrite(Reyeled[i], LOW); // and turning it off.
for (i = lpeye - 1; i >= 0; i--) {
digitalWrite(Leyeled[i], HIGH);
digitalWrite(Reyeled[i], HIGH);
digitalWrite(Leyeled[i], LOW);
digitalWrite(Reyeled[i], LOW);

but in this the "Reyeled" is dim, i can swap the pins plugs around, so left and right take the other's spots, and then "Leyeled" is weaker. i make the same change on the programing level instead, same issues i can use any pins and it will still leave one set less used. 

going to check mixing up the pins (even/odd) (l,r,l,r, etc) see what it does then, 

have now tried with pins 
nt Leyeled[] = {22,24,26,28}; // choose the pin for the LED
int Reyeled[] = {23,25,27,29 };
nt Leyeled[] = {13,11,9,7}; // choose the pin for the LED
int Reyeled[] = {12,10,8,6 };

(code tags added by moderator)

no luck

edit 2
all code is originally worked off of the loop function in the digital 1/0 section of the basics pdf

Code is distorted, plz re-post with "#" button in the bar above edit-box

Can we see the rest of your code? Specifically, are you setting the pins to output?

hey folks!

I'm a beginner to Arduino. I'm curious in knowing how many bits does the digital outpin pins give? 8 bits or 1 bit?

If they r 8 bits, can i play with them inorder to vary the output voltage from the digital out pin between 0-5volts?

need help.


You can use a PWM output pin with the analogWrite command and a low pass filter (resistor/capacitor) to yield an analog level between 0 and 5V in 1/255th increments.

You can also perform serial transfers to a DAC chip via several different methods to get an analog output.

You can also use 8 outputs feeding a string of resistors to make your own DAC:

then i may run shot of pins. isnt there any possibility to play with the output voltage obtained from a digital pin(not PWM).

Thanks for the help turns out the outputs were the issue, my loop only included half the pins, not doubling it after modifying original script.

A digital pin is either 0 or +5v.
The only way to make it look analog is to fake it by switching it on/off quickly. The longer it is on, the higher it will look.

or can i have a shift register that wil serve the purpose of fetching me 8 bit data taking only 3pin input from Arduino? is that possible?

if this is possible, hope i can vary the voltage through 3 digital pins.


Yes, you can connect the R2R ladder I discussed earlier and connect it to a shift register.
Or get an analog to digital converter chip and use that with I2C (2 wire) or SPI (3 wire) interface from the Arduino.

http://www.linear.com/product/LTC1257 for example, or browse the website for a different package

during the programming, i'l want to read analog input through any analog pin. can i use a variable to store this input value and access for further caluculation/comparions inbetween the sketch as and when required?

Sure. The analog pins all feed into the 1 ADC via internal multiplexer, which yields a 0 to 1023 value representing 0-5V (about 4.88mV per step).
Store it as an int, do what you want with it.

where does this int stores the value in controller? I’m more interested in knowing this.

in a variable that you declare in the code.
For example,

  Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
sending it to serial port once a second

int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
unsigned long currentTime = 0;  // the current millis counter
unsigned long previousTime = 0;  // the old millis counter
void setup() {
 Serial.begin (9600); 

void loop() {
  currentTime = millis();
  if ( (currentTime - previousTime) >= 1000) {
    // 1 seconed has passed, reset the previous time
    previousTime = currentTime;
    // read the value from the sensor:
    sensorValue = analogRead(sensorPin); 
    // send it out the serial port with a line feed
    Serial.println (sensorValue, DEC);  // send out 0-1023  based on what was read
  } // end of time pass check              
} // end of loop

new problem same project, in adding effects to i had a few working fades, or at least they worked with the Mega board, i picked up a Nano 3.1 for the more permanent setup and none of the fades work, it works on some LEDs, but the others are only off and one, at the respective points in the cycle, is this an issue i can fix?

the code again is just basic using the sin values to create a fade either out of both sets equally or each set going opposite each other

void fade () {// fade-------------------------------------------------------------
  for (int x=0; x<180; x++) {
    sinval = (sin(x*(3.1412/180)));
    lledval = int(sinval*250);
      for (i1 = 0; i1 <= lpeye; i1++){
        analogWrite(Leyeled[i1], lledval);
        analogWrite(Reyeled[i1], lledval);

void dualfade () {// fade-------------------------------------------------------------

  for (int x=0; x<180; x++) {
    sinval = (sin(x*(3.1412/180)));
    sinval2 = (sin(x*(3.1412/180)+3.14));
    lledval = int(sinval*250);
    rledval = int(sinval2*250);
      for (i2 = 0; i2 < lpeye; i2++){
        analogWrite(Leyeled[i2], lledval);
        analogWrite(Reyeled[i2], rledval);


(code tags added by moderator, and took out some extra blank lines)

Nano is '328 based, yes? If so itshas only 6 PWM output pins, 3,5,6 9,10,11.

Mega has many more PWM output pins that will support analogWrite.

Without seeing the pin assignments in these arrays
analogWrite(Leyeled[i2], lledval);
analogWrite(Reyeled[i2], rledval);
its hard to say if that is your problem.

Please [ code ] and [ /code ] (without spaces)
before & after your code listing, makes it a little easier to review. I fixed in the earlier post.

Thanks, and yes, the issue does have to do with PWM i am trying to run 8 digital without all of them having the pwm options. now i'm looking at 595's to see if i can work it through there, but it is currently slightly above my knowledge base, so need to do some research and trial and error testing, thanks for the help.

Take a look at TI's TLC5940. 16 PWM pins. Good support in the forum.