How many LED's can you run off an Arduino Uno

Hey Guys,

I'm building a lighting feature for my dissertation, I've finished my code, below if your interested.
I'm looking to turn the prototype into an actual light.
Does anyone have any advice for turning the breadboard into an actual product?

I'm unsure of what wires I need to replace the jumper wires, as the distance between the arduino and the actual light could be quite a distance in a live situation..

Also, does anyone know how many LED's you could power off of an Arduino Uno? I'm hoping to use at least 15-20
I'm currently using 3mm Blue Diffused LED 5k MCD, but I'm looking to change these to 1.8-2.4v Red LED's...

Any help appreciated,

Thanks
Sam

// LED gets brighter the less light the LDR recieves

#define LED1 9 // pin that LED is attached to
#define LED2 10
#define LED3 11
#define LED4 6

int Val = 0; // variable used to store the value coming from the sensor
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

long randNumber;

void setup() {

  
    pinMode(LED1, OUTPUT);  // LED is an OUTPUT
    pinMode(LED2, OUTPUT);  // LED is an OUTPUT
    pinMode(LED3, OUTPUT);  // LED is an OUTPUT
    pinMode(LED4, OUTPUT);  // LED is an OUTPUT
    randomSeed(analogRead(2 & 3));
                        // Analogue pins are autmatically set as inputs

}

void loop() {
     
  // READ SENSOR INOUT
 if ((Val = analogRead(0)) < 200)    // read the value from the sensor
                             // HIGHER NUMBER = MORE SENSITIVE
                             // LOWER NUMBER = LESS SENSITIVE
 {
 analogWrite(LED1, 255-Val);  // turn LED on at brightness set by sensor value
  analogWrite(LED2, 255-Val);  
    analogWrite(LED3, 255-Val);  // turn LED on at brightness set by sensor value
      analogWrite(LED4, 255-Val);  
 delay(10);    // stop the program for some time 
 }
 
 else if ((Val = analogRead(0)) > 200)
{  //RANDOMLY BLINK LED 1
  randNumber = random(0, 150000);
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > randNumber) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(LED1, ledState);
    //END OF RANDOM BLINK
    
  }
  {  // RANDOMLY BLINK LED 2
    randNumber = random(0, 100000);
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > randNumber) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   
    
        digitalWrite(LED2, ledState);
        if (ledState == HIGH)
            ledState = LOW;
         else
            ledState = HIGH;
            // END OF RANDOM BLINK
  }
  {  // RANDOMLY BLINK LED 3
    randNumber = random(0, 100000);
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > randNumber) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   
    
        digitalWrite(LED3, ledState);
        if (ledState == LOW)
            ledState = HIGH;
         else
            ledState = LOW;
            // END OF RANDOM BLINK
  }
  {  //RANDOMLY BLINK LED 4
  randNumber = random(0, 150000);
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > randNumber) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(LED4, ledState);
    //END OF RANDOM BLINK
    
  }
  }
  
  }
}
}
}

The max current per IO pin is 40mA but most people suggest keeping to 20. So that's roughly one LED per pin.

But the 328 has a max total of 200mA for the package.

So I would say as a rule of thumb 10 LEDs max, but 5 would be better (using my 1/2 max rule).


Rob

Are you limited to 5V supply?
If so, then 2 LEDs in series, 10 strings in parallel, NPN transistor to turn them off & on.
Or a ULN2803, 8 pins let you break them up into different segments.

A little known fact is that the 200mA is the limit on the supply pins. So keeping this down to 150mA suggests 10 LEDs at 15mA per LED. However, you can double that by driving half by sourcing current and the other half by sinking it.

Of course, I was thinking 200mA total with what goes in VCC comes out GND. But that's not the case when driving IO.


Rob

how many LED's you could power off of an Arduino Uno

LOL shield (http://www.makershed.com/ProductDetails.asp?ProductCode=MKJR3) has 126 charlieplexed LEDs.

With external drivers, port expanders or multiplexers and external power supply the answer to the question is more than the number of LEDs you can afford.

Hi Sam
I am new to all of this but I am quickly discovering one truth. For all intents and purposes the power supply on the Arduino is good enough to feed the brain but not the body. If you really want to illuminate something you will need to provide a secondary power source. In the end you will have one power source to the Arduino(brain) at between 3-5V and one to the LEDs(body) which can be almost any power value.

I wish I could tell you how to do this but I am still trying to figure it out myself.

Fred

In the end you will have one power source to the Arduino(brain) at between 3-5V and one to the LEDs

No what you end up doing is powering it all off an external supply.
You are mixing up power drawn from the arduino chip, power drawn from the arduino regulator and power drawn from an external supply.
Remember power is volts times current so you can have a supply capable of providing power but it doesn't have to, it will only supply the power the circuit needs.

http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html