why does my arduino lose power on led5-led7?

when i use my simple led chaser program led5-led7 lose power and are very dim. all leds have different pins, same ground ,and the same resistors here is the code can you tell me what is wrong

thank you

int led1 = 8;
int led2 = 9;
int led3 = 10;
int led4 = 11;
int led5 = 3;
int led6 = 4;
int led7 = 2;

void setup() {
pinMode (led1, OUTPUT);
pinMode (led2, OUTPUT);
pinMode (led3, OUTPUT);
pinMode (led4, OUTPUT);
void loop () {
digitalWrite(led1, HIGH);
digitalWrite(led1, LOW);
digitalWrite(led2, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, HIGH);
digitalWrite(led4, LOW);
digitalWrite(led5, HIGH);
digitalWrite(led5, LOW);
digitalWrite(led6, HIGH);
digitalWrite(led6, LOW);
digitalWrite(led7, HIGH);
digitalWrite(led7, LOW);

sort by: active | newest | oldest
You didn't set the pinmore for LEDs 5, 6, and 7. That's why they are not working right.
harry88 (author)  mpilchfamily5 years ago
Oh my God you are right how did I not notice that. Well that was my first program with arduino besides the blink example. its suprsing how fast you can learn the language with the getting started with arduino book. Man that was probably one of the stupidest mistakes ive ever made.

Thank you
Just wait. One of these days everything will be perfect except you will have used a : instead of a ;. Worst yet it will take you more then a day to figure it out. Little things like that happen to all of us.
Toby Robb5 years ago
Should you set the pinmode for leds 5,6 and 7 also? Will this turn off/on internal pullup/pulldown resistors?
frollard5 years ago
Have you tried swapping the leds? did you draw too much current and damage the arduino pin? Calculate your resistor value around less than 20mA and 5 volts source...

What happens if you swap the leds around (are some of them bad?)

There is no obvious reason for them to be bad unless the led is damaged, the resistor is wrong (triple check the colour codes/test with a multimeter), or the arduino is damaged.

It's not just happening to analog output (pwm) pins so I don't think its a bad analogwrite.