- Could you provide a brief explanation about your code lines:
byte lowLED = lowByte(leds);
byte midLED = highByte(leds);
byte highLED = leds >> 16;
Well at this point, you needed 24 bits. A byte is 8 bits, a "word" in C is (in this case) 16 bits and a "long" is 32 bits. I had to make "leds" a long to fit all the 24 bits. lowByte() is a function that picks out the least significant eight bits (and only 8 bits) of its argument. Similarly highByte() picks out the next higher eight bits - which is the highest eight bits for a "word" but if given a "long" is the high 8 bits of the lowest 16 bits!
So we have obtained the right hand most 8 bits, and the next left-most 8 bits to those. We now want the next left-most 8 bits. To do that I used the right-shift operator to simply shift 16 bits. Now "highLED" was defined as a "byte" so it only ever fits 8 bits! So however many bits were in that "long" after it was shifted, we only get the last (right-hand) 8 bits, which is as we wanted.
On this basis, this code would work just as well:
byte lowLED = leds;
byte midLED = leds >> 8;
byte highLED = leds >> 16;
and I think you can guess what the next - fourth line would look like.
But beyond four bytes, you would need to use something longer than a "long" and you would be better using a different structure - an array.
Also, using 74HC595s is terribly messy beyond 8 LEDs and you are better off using a LED driver - a MAX7219 and there are (or used to be pre-Covid-19) inexpensive modules on eBay or Aliexpress which make it easy to wire up. The MAX7219 drives a matrix of anything up to 64 LEDs and requires only one resistor and that bypass capacitor!
2) Could you give me a hint or a fraction of code which would allow me to to turn on and distinguish multiple LEDs at the time (not 1 by 1) For example: I want to turn on LED`S 1-5 and 7-9 at one moment and turn them off as well.
Well the simplest way of doing that is to write the pattern as a single word (or "long") but it really depends on exactly what you want to do.
PS: I am using 180 Ohm resistors to each LED
I hope wiring is more than understandable: https://drive.google.com/drive/folders/1kG1dHJVNNvXRRbT8o_LXfHvSX2mNG3_w?usp=sharing
It is understandable, except that I cannot see a wire connecting the ground of the registers - pin 8, bridged by the blue wires - to the actual ground. You would appear to be relying on the connection of pin 13 - Output Enable - to ground for the chip to function. Not a good idea!
If I understand you correctly, I should replace all these yellow wires with mentioned capacitors with as short terminals as possible, is that right?
No, not replace - a capacitor does not pass DC. To "bypass" the chip with a capacitor, you would need to connect it - as well as all the present connections (and of course, the proper ground) across each chip from pin 8 (ground) to pin 16 (Vcc).
PS: please ignore other registers, I am trying to understand adding them 1 by 1, for now I am only using first 3 (wired) registers
If you wire them in, they will simply "echo" the pattern of earlier registers - which is what your original experience was.
Google drive is inconvenient for posting photos to the forum. Within limits, you can attach them here and they can be embedded into the discussion thread.