168Views5Replies

Author Options:

why does my arduino lose power on led5-led7? Answered

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);
delay(99);
digitalWrite(led1, LOW);
delay(99);
digitalWrite(led2, HIGH);
delay(99);
digitalWrite(led2, LOW);
delay(99);
digitalWrite(led3, HIGH);
delay(99);
digitalWrite(led3, LOW);
delay(99);
digitalWrite(led4, HIGH);
delay(99);
digitalWrite(led4, LOW);
delay(99);
digitalWrite(led5, HIGH);
delay(99);
digitalWrite(led5, LOW);
delay(99);
digitalWrite(led6, HIGH);
delay(99);
digitalWrite(led6, LOW);
delay(99);
digitalWrite(led7, HIGH);
delay(99);
digitalWrite(led7, LOW);
delay(99);
}

Discussions

0
None
mpilchfamily

Best Answer 6 years ago

You didn't set the pinmore for LEDs 5, 6, and 7. That's why they are not working right.

0
None
harry88mpilchfamily

Answer 6 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

0
None
mpilchfamily

6 years ago

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.

0
None
Toby Robb

6 years ago

Should you set the pinmode for leds 5,6 and 7 also? Will this turn off/on internal pullup/pulldown resistors?

0
None
frollard

6 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.