Dim display when lighting multiple LEDs

Hi, noob here, just finishing my first project...

I have an Arduino Nano connected by I2C to a 1602 Display via a 3x4 keypad. Also connected are 3 74HC595 shift registers in series, each controlling 8 LEDs, for a total of 24. Each LED has an inline resistor.

My code is used to switch on a single LED. After a certain idle time, the code randomises 1 LED from each shift register to switch on, and this randomises continually after 2 seconds. So far so good.

There's also a password which turns on ALL LEDs at once, and waits for a key press to turn them off again. It is while all the LEDs are on that the contrast on the Display reduces significantly. The backlight looks to be unaffected.

Is this to be expected, or does there seem to be a fault? Also, as this is a prototype, my intention is for the system to handle several more shift registers populated with LEDs. Should I assume that this will decrease the contrast even more?

Thank you for any help.

Wen we see your code, posted according to the instructions and preferably a schematic, we may be able to suggest something. :grinning:

This is a simplified version of the code, just to show what's happening with the display.

#include <Keypad_I2C.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins[ROWS] = {2, 7, 6, 4};
byte colPins[COLS] = {3, 1, 5};

Keypad_I2C I2C_Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS, 0x20, 1);

const int dataPin = 10;
const int latchPin = 11;
const int clockPin = 12;

void setup() {
  Wire.begin();
  I2C_Keypad.begin();
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("LCD Display");
  lcd.setCursor(0, 1);
  lcd.print("Brightness Test");
}


void loop() {

  allOn();
  delay(1000);
  allOff();
  delay(1000);
}

void allOn() {
  digitalWrite(latchPin, LOW);
  for (int i = 0; i < 6; i++) {
    shiftOut(dataPin, clockPin, LSBFIRST, 0b11111111);
  }
  digitalWrite(latchPin, HIGH);
}

void allOff() {
  digitalWrite(latchPin, LOW);
  for (int i = 0; i < 6; i++) {
    shiftOut(dataPin, clockPin, LSBFIRST, 0b00000000);
  }
  digitalWrite(latchPin, HIGH);
}

Schematic_Main Lighting Module.pdf (166 KB)

1 second video of the display.

20200626_102905_2.mpg (1.18 MB)

PWR layer is missing in your schematics.

Where do you connect power ?

MAS3:
PWR layer is missing in your schematics.

Where do you connect power ?

USB from laptop to Nano.

Create a sufficient 5 volt supply.
The nano can't handle the current you're drawing, so the 5 volts starts to collapse.

You shouldn't power 42 LEDs plus some other devices through your Arduino.
If you still need to power your Arduino through the USB connector, create another supply for your peripherals.

This is the perfect excuse to get yourself a multimeter so you can see for yourself what happens.

MAS3:
Create a sufficient 5 volt supply.

So maybe if I install a 5.5/1.2 jack that accepts a 9v or 12v power adapter, then split that voltage between devices using something (is it a buck convertor?), that will solve the problem?

Maybe.

A converter like that has an effectiveness of 85 % (which is pretty good), and it should be able to handle the needed current.
Your adapter should also be capable of sourcing the current you need with the converter plus the peripherals (and i would also try to see if the Arduino could be powered this way too).

So you need to do a bit of calculation to find out what current(s) you need, before you got out shopping for parts and devices to add to your setup.
It's smart to have sources that can handle a bit more current than what your calculations tell you you need.
Remember: current is drawn, not forced into circuits.

So, I've attached a pdf of my amended schematic. I've added a VCC and GND to the top left. This will be either a 9v or 12v power adaptor.

I've added two LM7805 Linear Voltage Regulators. These are capable of handling 1A. One of which is enough for 48 LEDs each drawing 20mA (total 0.96A), and the other will power the Arduino, keypad, and LCD display.

The "Output" to the right of the sheet will be used to cascade more boards, each with up to 48 more LEDs, but WITHOUT the Arduino, keypad and display. The 9v/12v power from the adaptor will feed directly to each additional board to an LM7805. So each board of LEDs will have it's own 5v regulated supply.

To finish off, I've added 100uF capacitors after each voltage regulator, something to do with smoothing, so I've been told.

That about covers these initial amendments. Hopefully they're good amendments.

Schematic_Main Lighting Module_2020-06-26_22-54-32.pdf (172 KB)

OK.

Your schematics are OK, much better than average.
Be aware of double names for nets.
Your new 12 volt supply is called VCC, but your components also have VCC which are supposed to be 5 volts.
You'll get in trouble whenever you are going to create larger schematics, so start preventing this now.
Your modular setup is nice.

A 7805 is "old school".
It works, but the 85 % efficiency i mentioned earlier is no where close to what these things do.
They literally burn off the not wanted energy.
So to get 5 volts out of a 12 volts supply, 7 volts have to be turned into heat (dissipated).
They will get really hot, and would operate at an efficiency of about 41.7 %

If you consult a 7805 datasheet, you'll find that just a 100 µF capacitor at the output is not recommended.
So add a 100 nF capacitor to that, and use capacitors at the input too.

A step down buck converter module might turn out cheaper after all, handle more current, and won't get too hot.

@MAS3

I can't thank you enough for all the advice. It's taken me so long to get the program to work (There's a LOT more to it than the example program I posted just to explain the contrast problem I'm having).

But I'm very new to the electronic, and hadn't realised just how involved it is. There's so much to learn.

Thank you for the compliments and advice on the schematics. I understand what you mean by the VCC, and I guess this error creapt in due to me adding it quickly. I'll watch for things like that in future.

I'll search for a 5v adaptor, as this would negate the need to drop any voltage, and I'll watch for the rating of the capacitors too.

QUESTION.. If I use a 5v power adaptor, does that mean I don't need a buck converter? And as long as the 5v power adaptor is capable of supplying at least 1A for each board of 48 LEDs, that should be okay?

indie55:
So maybe if I install a 5.5/1.2 jack that accepts a 9v or 12v power adapter, then split that voltage between devices using something (is it a buck converter?), that will solve the problem?

That is a rather bizarre statement. :astonished:

You have a system using digital logic that operates at 5 Volts. Why would you want to use 9 or 12 V?

USB "phone chargers" rated at 2.1 A are readily available and provide regulated 5 V.

That said, you have chosen - for some reason - to use 74HC595s to drive your LEDs and you specify 220 Ohm resistors. Now the 74HC595 has an absolute maximum current specification of 70 mA for the device so six of them should never be drawing more than 420 mA. Let's see - LED voltage drop 2 V, "typical" voltage drop of the output driver at 20 mA would be 0.5 V, so 2.5 V / 220 Ohms is about 12 mA so eight times that is 96 mA - you are clearly overloading the 74HC595 with all LEDs on and the total current draw would be about 575 mA, so let's say 600 mA and a 1 A power supply should actually suffice.

Unfortunately "PDFs" cannot be shown directly in webpages such as this thread. :cold_sweat:

And if all you want is to display on LEDs, it would be far more sensible to use these readily available MAX7219 modules to drive 64 LEDs at a time.

You can just wire your own LEDs as a matrix instead of the one provided. Current consumption at full brightness is 320 mA.

Attached is a mock up of what I'm trying to do. Light an individual LED. If all I do is light 1 at a time, everything works. However, for testing purposes, it's helpful to be able to turn all LEDs on at once. (This is what happens with our 3rd party system, but I'm trying to design one we can use instead of paying a LOT of money to a 3rd party.)

I see from the data sheet that the MAX7219 has its own built in "all on" test. Very handy.

To be honest, I skipped straight past these, thinking that the 8x8 grid was the only way to use them, as I see everyone use them as a scrolling display. But if I can connect individual LEDs to them and route them to different places, then they look ideal. Especially if I can use several of them.

Thank you for pointing me in a completely different direction. I hate to trash the code I so lovingly put together, but it's all a learning process.

Thank you again.

20200627_003610.jpg

Yes, for that sort of display, the MAX7219 (module) would be perfect. :grinning:

Excellent. Thank you so much. Back to the drawing board tomorrow for more research and learning. It's all good stuff.

For now, it's bed time. 2am here in the UK.

Asking for an Amp from a 78 series regulator is going to need a VERY good heatsink. The linear regulators are best used when you need a clean power supply, for all digital purposes a switched mode power supply is far better. These are the "Buck converters" that you will have read about.