Can anyone please help me fix this LED flickering? LEDs connected in parallel

Here is my setup. This is about my arduino uno controlled binary coded decimal clock. But please, do NOT merge this thread. please. I noticed yesterday that one of the LEDs started flickering. It kind of flickers and dims, it is quite noticeable. Sometimes, it will flicker, dim and return to its normal brightness. I have marked it with a red arrow below:

I am not sure why it is flickering. Arduino Uno is fed by a 9 V power supply. The LEDs specs are: 1W, 350ma, 3.2fV. I am using a separate power supply adapter for the LEDs. 3.5 volt, 3 amp DC adaptor. The grounds of both systems are joined together. The LEDs are wired through 1 ohm resistor to try and balance out the drawn current. As you can see in the general layout above, the LEDs are controlled through NPN transistors. Arduino signals control the transistor bases.

I know very little about electronics. I really appreciate this forum but whenever I try to ask something, almost always somebody jumps in and starts complaining about the fact that I know very little about electronics. I know that I know very little about electronics. There is no point proving that to me. If you can help and if you have some constructive feedback to help me, then I will be very very grateful to you. Please don't be saying how retard I am for asking something like this.

I'm sure most of you guys are professionals and know all the ins and outs of electronics. But there are also a lot of guys like me who don't know what they are doing but are here to learn something.

Cheers.

You appear to be using pins 0 and 1 for your application and these are also used for any serial activity. Is the affected led connected to one of these pins ?
You say leds are connected in parallel, but does each led have its own current limiting resistor ?
A schematic diagram would make the project easier to follow. The Fritzing diagram is not very clear.

6v6gt:
You appear to be using pins 0 and 1 for your application and these are also used for any serial activity. Is the affected led connected to one of these pins ?
You say leds are connected in parallel, but does each led have its own current limiting resistor ?
A schematic diagram would make the project easier to follow. The Fritzing diagram is not very clear.

Yes, sir, you are right!
The affected LED is indeed connected to pin 1. And yes, each LED has its own resistor in series with the LED.

I am posting the code so you can have a look. Please note that the actual code that is in the arduino right now, is slightly different. When I was using the following code the flickering did not occur. Or at least, I did not notice it. The only thing that is different is that I added the "#define INTERVAL" feature in order to try and adjust the arduino time drifting. Otherwise, the code is the same.

Is there anything I can do about the flickering? Could it be related to #define Interval feature in the code? is there any way, to get rid of the flickering?

/*
An open-source binary clock for Arduino. 
Based on the code from by Rob Faludi (http://www.faludi.com)
Code under (cc) by Daniel Spillere Andrade, www.danielandrade.net
http://creativecommons.org/license/cc-gpl
*/

int second=0, minute=0, hour=0; //start the time on 00:00:00
int munit,hunit,valm=0,valh=0,ledstats,i;

void setup() { //set outputs and inputs
pinMode(1, OUTPUT);pinMode(2, OUTPUT);pinMode(3, OUTPUT);pinMode(4, OUTPUT);pinMode(5, OUTPUT);
pinMode(6, OUTPUT);pinMode(7, OUTPUT);pinMode(8, OUTPUT);pinMode(9, OUTPUT);pinMode(10, OUTPUT);
pinMode(11, OUTPUT);pinMode(12, OUTPUT);pinMode(13, OUTPUT);

pinMode(0, INPUT);
}

void loop() {

static unsigned long lastTick = 0; // set up a local variable to hold the last time we moved forward one second
// (static variables are initialized once and keep their values between function calls)
// move forward one second every 1000 milliseconds

if (millis() - lastTick >= 1000) {
	lastTick = millis();
	second++;

}

// move forward one minute every 60 seconds
	if (second >= 60) {
	minute++;
	second = 0; // reset seconds to zero
}

// move forward one hour every 60 minutes
if (minute >=60) {
	hour++;
	minute = 0; // reset minutes to zero
}

if (hour >=24) {
	hour=0;
	minute = 0; // reset minutes to zero
}

	munit = minute%10; //sets the variable munit and hunit for the unit digits
	hunit = hour%10;


	ledstats = digitalRead(0);  // read input value, for setting leds off, but keeping count
	if (ledstats == LOW) {
    
	for(i=1;i<=13;i++){
	digitalWrite(i, LOW);}
  
	} else  {

	//minutes units
	if(munit == 1 || munit == 3 || munit == 5 || munit == 7 || munit == 9) {  digitalWrite(1, HIGH);} else {  digitalWrite(1,LOW);}
	if(munit == 2 || munit == 3 || munit == 6 || munit == 7) {digitalWrite(2, HIGH);} else {digitalWrite(2,LOW);}
	if(munit == 4 || munit == 5 || munit == 6 || munit == 7) {digitalWrite(3, HIGH);} else {digitalWrite(3,LOW);}
	if(munit == 8 || munit == 9) {digitalWrite(4, HIGH);} else {digitalWrite(4,LOW);}

	//minutes 
	if((minute >= 10 && minute < 20) || (minute >= 30 && minute < 40) || (minute >= 50 && minute < 60))  {digitalWrite(5, HIGH);} else {digitalWrite(5,LOW);}
	if(minute >= 20 && minute < 40)  {digitalWrite(6, HIGH);} else {digitalWrite(6,LOW);}
	if(minute >= 40 && minute < 60) {digitalWrite(7, HIGH);} else {digitalWrite(7,LOW);}

	//hour units
	if(hunit == 1 || hunit == 3 || hunit == 5 || hunit == 7 || hunit == 9) {digitalWrite(8, HIGH);} else {digitalWrite(8,LOW);}
	if(hunit == 2 || hunit == 3 || hunit == 6 || hunit == 7) {digitalWrite(9, HIGH);} else {digitalWrite(9,LOW);}
	if(hunit == 4 || hunit == 5 || hunit == 6 || hunit == 7) {digitalWrite(10, HIGH);} else {digitalWrite(10,LOW);}
	if(hunit == 8 || hunit == 9) {digitalWrite(11, HIGH);} else {digitalWrite(11,LOW);}

	//hour
	if(hour >= 10 && hour < 20)  {digitalWrite(12, HIGH);} else {digitalWrite(12,LOW);}
	if(hour >= 20 && hour < 24)  {digitalWrite(13, HIGH);} else {digitalWrite(13,LOW);}

	}

	valm = analogRead(0);    // add one minute when pressed
	 if(valm<800) {
	 minute++;
	 second=0;
	 delay(250);
	}
  
	valh = analogRead(5);    // add one hour when pressed
	 if(valh<800) {
	 hour++;
	 second=0;
	 delay(250);
	}


}

The LEDs specs are: 1W, 350ma, 3.2fV.

In which case you should not be driving the LED with a simple resistor as a current limiter. You need a constant current drive for high power LEDs.

This is constructive and you have been told this before I believe, but you refuse to do anything about it.

Grumpy_Mike:
In which case you should not be driving the LED with a simple resistor as a current limiter. You need a constant current drive for high power LEDs.

This is constructive and you have been told this before I believe, but you refuse to do anything about it.

It is not because I refused to do so. I don't know how to do it. Do I need 13 x LED drivers in my binary clock application? or only one? If only 1, then I already have a DC power adaptor. If individual, then it is going to be to costly to make.

And still, is there anything I can do to eliminate flickering of the LED connected to pin 1? could #define Interval be even remotely related to this flickering? i started noticing it after I added that bit to the code.

1 Like

6v6gt:
You appear to be using pins 0 and 1 for your application and these are also used for any serial activity. Is the affected led connected to one of these pins ?
You say leds are connected in parallel, but does each led have its own current limiting resistor ?
A schematic diagram would make the project easier to follow. The Fritzing diagram is not very clear.

If I am not using Serial.begin() in my program, can this still be a problem? Do I have to use "outb(UCSRB, 0);" to stop interference?

arduinoware:
. . .
And still, is there anything I can do to eliminate flickering of the LED connected to pin 1? could #define Interval be even remotely related to this flickering? i started noticing it after I added that bit to the code.

There is no #define statement in the code you have posted. If the code you are currently running has Serial.begin(), Serial.print() etc. then you should not use pins 0 or 1. You can use an digitalWrite() etc also on analog pins A0 to A5 if you want to see if changing the pin makes the problem appear to go away.

Post crossed with your latest.

It is not because I refused to do so. I don't know how to do it. Do I need 13 x LED drivers in my binary clock application? or only one? If only 1, then I already have a DC power adaptor. If individual, then it is going to be to costly to make.

If you want individual control of LEDs then you have to have individual constant current drivers.

A constant current driver is not a DC power adaptor, you can have one power adaptor driving many constant current circuits.

Read the how to use this forum sticky post for information on how to respond to advice you get here.

But please, do NOT merge this thread.

Why not? The problem you are having has already been covered/answered in your previous (merged) thread.

Pete

arduinoware:
It is not because I refused to do so. I don't know how to do it. Do I need 13 x LED drivers in my binary clock application? or only one? If only 1, then I already have a DC power adaptor. If individual, then it is going to be to costly to make.

The constant current driver not going to be costly to make, it need only one extra transistor and few resistors, how can that be costly.

Hi,
Dont comment much but to give you some advice.
You dont learn if you dont try and blowing things up is going to happen to anyone working in electronics no matter how good they are.
Now to your question, more components in your project means more to go wrong (that includes code) so elimation
/isolation of the fault is first.
You have code, uno, power supply, drivers and leds. So lets narrow the field some.
First create a code that turns the leds on one after the other till they are all on and check your power supply voltage to see if it drops lower than what you need. Turn the leds on slowly and if it does you will then know how many leds you can drive at one time.
If this does not exceed the amount you run on the clock at any one time thats ok.
Next reload your clock code and then change the wire going from the uno to the flickering led to one of the others (swap them) if the same led still flickers then the fault is most likely in the led or driver but if the flicker moves to the other led then you have a uno or code problem.
From there its just a matter of eliminating things till you are left with the faulty one.
Take note of what others have said as this will help the further along you go. If nothing else you will have more to tell people here.

In ref to the comments about constant current and thermal runnaway, lets take note of the fact that you may not know a lot at this time (people, remember what it was like when you started?) The first leds all used a fixed voltage sourse and a resistor (I think that makes it a constant current source dosent it?) This is not what i would call a stable current source but it all depends.

Thermal runnaway is causes when components heat up during use and in doing so some draw more current. With more current comes more heat and so on and so on untill it melts and usualy destroys everything attached to it.
The constant current source sould stop this but having seen the quality of some, this doesnt always work.

Hope this helps some with your actual question.

How does that circuit work?
What's the 0.7 factor coming from?
That current is 0.7/R in A, and independent of supply voltage & forward voltage?

(edit)The BC547 is a poor example as it can handle only 100 mA while the LED in question is rated 350 mA.

0.7 factor is the voltage drop from the base to emitter of the transistor should not change.

So in this case a 2 ohm, >1/4W resistor, and an appropriate transistor that can handle 350 mA and some 400 mW for a 5V power supply.

This wouldn't work with the 3.5V supply as you need 3.2V for the LED plus 0.7V for the current limiting circuit to work, right?

(edit: corrected mA to mW)

el_supremo:
Why not? The problem you are having has already been covered/answered in your previous (merged) thread.

Pete

Yes, but as you can see, on that other post the answers are not as detailed as those here. If I wanted it merged, I would have posted it there. I have learned a lot of things by simple posting it separately. I'm sure it will be useful for other people too. Do you mind?

6v6gt:
There is no #define statement in the code you have posted. If the code you are currently running has Serial.begin(), Serial.print() etc. then you should not use pins 0 or 1. You can use an digitalWrite() etc also on analog pins A0 to A5 if you want to see if changing the pin makes the problem appear to go away.

Post crossed with your latest.

Thanks. Still doing some troubleshooting. You said I could use one of the analog pins as digitalWrite() to see if something changes. In case, my issue turns out to be Pin related, can I leave it connected to one of the analog pins permanently or did you mean I can only use it temporarily? Thanks.

Daz1712:
Hi,
Dont comment much but to give you some advice.
You dont learn if you dont try and blowing things up is going to happen to anyone working in electronics no matter how good they are.
Now to your question, more components in your project means more to go wrong (that includes code) so elimation
/isolation of the fault is first.
You have code, uno, power supply, drivers and leds. So lets narrow the field some.
First create a code that turns the leds on one after the other till they are all on and check your power supply voltage to see if it drops lower than what you need. Turn the leds on slowly and if it does you will then know how many leds you can drive at one time.
If this does not exceed the amount you run on the clock at any one time thats ok.
Next reload your clock code and then change the wire going from the uno to the flickering led to one of the others (swap them) if the same led still flickers then the fault is most likely in the led or driver but if the flicker moves to the other led then you have a uno or code problem.
From there its just a matter of eliminating things till you are left with the faulty one.
Take note of what others have said as this will help the further along you go. If nothing else you will have more to tell people here.

In ref to the comments about constant current and thermal runnaway, lets take note of the fact that you may not know a lot at this time (people, remember what it was like when you started?) The first leds all used a fixed voltage sourse and a resistor (I think that makes it a constant current source dosent it?) This is not what i would call a stable current source but it all depends.

Thermal runnaway is causes when components heat up during use and in doing so some draw more current. With more current comes more heat and so on and so on untill it melts and usualy destroys everything attached to it.
The constant current source sould stop this but having seen the quality of some, this doesnt always work.

Hope this helps some with your actual question.

Thanks a lot. Yes, I will use your troubleshooting guidance. By the way, if it turns out to be arduino related, can I use one of the analog pins (on the left side of arduino uno) as digitalWrite (as in output) ?

Thank you very much.

billhowl:
The constant current driver not going to be costly to make, it need only one extra transistor and few resistors, how can that be costly.

Thanks. Got a couple of questions though, if you don't mind.

  1. So, the 3K3 resistor is constant right? regardless of the setup should I use 3K3 resistor between the arduino output pin and the transistor base?? because right now I am only using a 330 ohm resistor between the arduino signal and npn transistor base.

  2. Secondly, can anyone specify which npn transistor(s) and resistors I can use for this setup, if I will be using 5 volt or 4 volt power supply? Because I have a 4V setting on my universal power adaptor too. I am wondering if I should be using that instead of 5 Volts. But please don't change the subject, I am mainly trying to learn which transistor and resistor I should use. The guy at local electronics shop is a complete douchebag and every time I ask for guidance, he says: ""No, no, no, no. There are 20000 types of transistors. You gotta tell me which one."" Sometimes, I wonder if he is on arduino forum too. :))

Thanks.

wvmarle:
So in this case a 2 ohm, >1/4W resistor, and an appropriate transistor that can handle 350 mA and some 400 mW for a 5V power supply.

This wouldn't work with the 3.5V supply as you need 3.2V for the LED plus 0.7V for the current limiting circuit to work, right?

(edit: corrected mA to mW)

Thanks. But what did you mean by "some 400mW for the 5v supply"?? Can you please elaborate? I am using 13 LEDs. But they are individually controlled. Are you referring to the total capacity of the 5V power supply or what exactly do you mean? please explain.

arduinoware:
Thanks. But what did you mean by "some 400mW for the 5v supply"?? Can you please elaborate?

Yes, that was a typo.
Corrected it when I saw your message.

That power is because there will be 400 mW for the transistor to dissipate.
Power supply 5V - 3.2V to the LED, 0.7V to the bottom transistor (if I understand the circuit correctly that one doesn't carry any current - still hoping for a more detailed explanation by @billhowl), 1.1V left for the top transistor to drop. 350 mA x 1.1V = 385 mW.

To select a suitable transistor: open up digikey.com or mouser.com web site, set all your requirements (at least you'll want to know the minimum voltage, power rating, CE current, package type), then get the cheapest available that does what you need it to do.