really dim LED's

So in this i have 4 leds and a potentiometer, and when the leds are touching using a 5v test they work, but when they input power through the computer they are really dim, except when they blink. they continue to blink at the correct brightness, but when not blinking they are incredibly dim.

conditional_cookies.ino (4.57 KB)

and when the leds are touching using a 5v test they work,

Not quite sure what that means but:-
That would imply a hardware problem, so:-

  1. Post your schematic and
  2. Post a photograph of your wiring

Yeah... I don't see anything obviously wrong, but can we see a schematic? Do you have current-limiting resistors on every LED?

BTW - You really need to learn about loops. A [u]for-loop[/u] would really simplify the parts where you are blinking the same pattern over-and-over. In addition to for-loops (and you main loop) there are while-loops and do-while loops.

Loops and conditional branching (if-statements, etc.) are the two most important concepts in programming.

Grumpy_Mike:
Not quite sure what that means but:-
That would imply a hardware problem, so:-

  1. Post your schematic and
  2. Post a photograph of your wiring

I will try when i can but i am learning in a class environment and am about to go on spring break. Also in the class we call it a 5 volt test (5v) so we know the led lights up using the five volt on the arduino. Probably should have known that wasn't a common term

DVDdoug:
BTW - You really need to learn about loops. A [u]for-loop[/u] would really simplify the parts where you are blinking the same pattern over-and-over. In addition to for-loops (and you main loop) there are while-loops and do-while loops.

Thanks for the advice, im new to arduino and am learning about it in a class that i have and this will most likely be helpful. I just googled how to do a function in loop once and used the first thing that came up.

dmitchell18:
I just googled how to do a function in loop once and used the first thing that came up.

Since you are obviously a student, here is some sage advice. Dig deeper. Don't ever just stop at the first thing that comes up unless you truly don't care about something at all. You get out what you put in. Don't just take the easy way because it is easy.

Do you have a resistor in line with each LED? You need one about 220 ohm, too high and it will look dim.

Or you could be that you have damaged your LED by doing the 5V test. If it has no resistor you will damage the LED connecting it directly to 5V, and a damaged LED is dim.

When they are dim, are they supposed to be off?

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

@dmitchell18

Tell us what you think this is doing for you:
while(1);

The case where potval2 equals seven also requires some closer attention.

Hi,
OPs code;

int potent = A4;
float  potval;
int led1 = 12;
int led2 = 11;
int led3 = 10;
int led4 = 9;
void setup() {
Serial.begin(9600);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(potent, INPUT);
}

void loop() {
  potval = analogRead(potent);

 int potval2 = map(potval,0,1023,0,9);
 Serial.println (potval2);
    if (potval2 == 9) {
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(100);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(100);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(1000);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(100);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(100);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(1000);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(100);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(100);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(1000);
    while(1);
  }  
  
  else  {if (potval2 == 0) {
      digitalWrite(led1, false);
      digitalWrite(led2,  false);
      digitalWrite(led3, false);
      digitalWrite(led4, false);
    }
   if (potval2 == 1) {
       digitalWrite(led1, true);
     }
   if (potval2 == 2) {
    digitalWrite(led2, true);
   }
  if (potval2 == 3) {
    digitalWrite(led3, true);
  }
  if (potval2 == 4) {
    digitalWrite(led4, true);
  }
  if (potval2 == 5) {
      digitalWrite(led1, false);
      digitalWrite(led2,  false);
      digitalWrite(led3, false);
      digitalWrite(led4, false);
  }
  if (potval2 == 6) {
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(100);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(100);
    digitalWrite(led1, true);
    digitalWrite(led2, true);
    digitalWrite(led3, true);
    digitalWrite(led4, true);
    delay(100);
    digitalWrite(led1, false);
    digitalWrite(led2, false);
    digitalWrite(led3, false);
    digitalWrite(led4, false);
    delay(1000);
  }
  if (potval2 == 7);    {
  digitalWrite(led1, false);
  digitalWrite(led2, false);
  digitalWrite(led3, false);
  digitalWrite(led4,false);
  }

  if (potval2 == 8) {
    delay(200);
    digitalWrite(led1, true);
    delay(200);
    digitalWrite(led2, true);
    delay(200);
    digitalWrite(led3, true);
    delay(200);
    digitalWrite(led4, true);
    delay(200);
  }
}

}

Tom.... :slight_smile: