Not enough power to light 5 LEDs at full brightness

Hello everyone.

I just started learning Arduino using the Starter Kit 6 days ago.
I'm currently at Project 05 "Mood Cue."

For those not familiar with this project, it's basically a Potentiometer moving a servo motor 180 degrees.

Yes this project has no LEDs in it, but I decided to "upgrade" this project by adding 5 LEDs and let them light up as the angle from the Potentiometer increases.

I added the LEDs to test my understanding, and I'm glad to say that the added program code worked!

However, it seems that the LEDs don't receive enough power for them to light up at full brightness.

In the circuit, I have :

-Servo Motor
-100uF Capacitor x2
-LED x5
-220ohm resistor x5
-Potentiometer.

I powered it using USB.

So how do I add more power?

Thanks in advance!

Code

#include <Servo.h>
Servo myServo;
int const potPin = A0;
int potVal;
int angle;


void setup() {
  myServo.attach(9);

  Serial.begin(9600);
  for(int pinNumber = 2; pinNumber<7; pinNumber++){
  pinMode(pinNumber, OUTPUT);
  digitalWrite(pinNumber, LOW);
  }
}
void loop() {
  potVal = analogRead(potPin);
  Serial.print("potVAL: ");
  Serial.print(potVal);
  angle = map(potVal, 0, 1023, 0, 179);
  Serial.print(", angle: ");
  Serial.println(angle);
  myServo.write(angle);
  delay(1);

    if(angle < 30){
      digitalWrite(2, LOW);
      digitalWrite(3, LOW);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
    }else if(angle >= 30 && angle < 60){
      digitalWrite(2, HIGH);
      digitalWrite(3, LOW);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
    }else if(angle >= 60 && angle < 90){
      digitalWrite(2, HIGH);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
    }else if(angle >= 90 && angle < 120){
      digitalWrite(2, HIGH);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
    }else if(angle >= 120 && angle < 150){
      digitalWrite(2, HIGH);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
    }else if(angle >= 150 && angle < 180){
      digitalWrite(2, HIGH);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, HIGH);
    }
}

Please post a schematic of your project (pencil and paper and a photograph is good enough) and your code

Have you set the pinMode() of the LED pins to OUTPUT ?

Instructions on how to post code here!

UKHeliBob:
Please post a schematic of your project (pencil and paper and a photograph is good enough) and your code

Have you set the pinMode() of the LED pins to OUTPUT ?

Yes I have set them all to OUTPUT.

I have modified my original post to include both photo and code.

Thanks in advance!

Arduino_project5.jpg
10k resistors (brown-black-orange) will not light the LEDs very bright at all (300 µA) - try 1k (brown-black-red for 3 mA) or 470 Ohm (yellow-purple-brown) which should be in your kit as they are very common values.

Powering via USB to operate a servo may not be adequate - a separate 5 V power supply such as a USB "phone charger" rated at 1 A or more connected directly to the servo might be better. :sunglasses:

Paul__B:
Arduino_project5.jpg
10k resistors (brown-black-orange) will not light the LEDs very bright at all (300 µA)

Thanks! Silly me, I thought that the 10K resistors were the 220 ohm ones. I mixed them up. I placed 220 and it lights up perfectly bright.

Now, for the future, if I wanted to place 100 LEDs on my circuit, how can I add more power to light them all? I still would like to know.

I would like to build a little control panel for my kid to have a lot of buttons/switches and LEDs. Something like a car or an aircraft for him to play with.

Thanks in advance.

I think that using 220 Ohm resistors will light the LEDs very bright, annoyingly so in fact if your LEDs are modern, good quality and efficient LEDs though the use of red encapsulation/ diffusion is not so common in modern 5 mm LEDs so I am inclined to wonder whether yours are old stock!

If you want to operate 100 LEDs, you potentially have three problems, the first being wiring them all and including current limiting resistors! :astonished:

The second is that there is a strict limit on the total current that the microprocessor can switch - something in the order of 200 mA. With 220 Ohm resistors and red LEDs drawing 14 mA each, that limit would be 14 LEDs. :grinning: And of course the third problem would be having sufficient control pins to drive 100 LEDs.

Well now, we start with the point that you do not need to drive all LEDs at 14 mA, nor do we need to drive them all the time even if you wish all to appear on at once. The solution for all problems is to multiplex them. To do that, you use one or more MAX7219 chips. These are designed to drive (up to) 8 by 8 matrix arrays by multiplexing one of eight rows at a time at 40 mA per LED, giving an average current of 5 mA which is plenty to drive an efficient LED, visible in daylight.

Just start by buying two or three of these kits on eBay:

Or these ones

which used to be more expensive but are now actually cheaper and more useful if you wish to stack matrix arrays.

The point is that you do not need to install the matrix arrays from the kits themselves - or their socket pins, but can just solder to the positions on the PCB and you have a durable and reliable assembly to drive your own matrixed arrays - which may be just independent LEDs in whatever arrangement you wish.

Why did I say two or three? Well, you probably should fully assemble the first one as the matrix with which it comes and practice programming it. Then the second one for your current project and the third one - for the next! :grinning:

Considering the cost, it makes no sense to just buy one!

hzraikat:
Thanks! Silly me, I thought that the 10K resistors were the 220 ohm ones. I mixed them up.

Once you can read resistor colour bands without thinking, you won't be able to make this mistake again!
brown-black-orange just screams "10k" to my brain (as does brown-black-black-red for 5-band resistors!)

MarkT:
Once you can read resistor colour bands without thinking, you won't be able to make this mistake again!

Amen to that! :grinning: