Thanks LarryD, Your code is working fine now, but it's a bit cumbersome... Same thing, with my understanding of use of mask now, and with help and explanation of Grumpy_Mike (Thanks!) my similar code now:
int LEDPin [15] = { 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50 }; // pin numbers used for LEDs
int Pattern1 [14] = { 0b10000000000000, 0b11000000000000, 0b11100000000000, 0b11110000000000, 0b11111000000000, 0b11111100000000, 0b11111110000000, 0b11111111000000, 0b11111111100000, 0b11111111110000, 0b11111111111000, 0b11111111111100, 0b11111111111110, 0b11111111111111 };
int Pattern2 [14] = { 0b00000000000001, 0b00000000000011, 0b00000000000111, 0b00000000001111, 0b00000000011111, 0b00000000111111, 0b00000001111111, 0b00000011111111, 0b00000111111111, 0b00001111111111, 0b00011111111111, 0b00111111111111, 0b01111111111111, 0b11111111111111 };
int Pattern3 [8] = { 0b10000000111000, 0b11000001111100, 0b11100011111110, 0b11111111111111, 0b01111111000111, 0b00111110000011, 0b00011100000001, 0b00000000000000 };
// Patterns - each binary number represents one frame
void setup() {
// use a for loop to initialize each pin as an output, 15th pin to be used for quick strobing bright white LEDs here and there...
for (int i = 0; i < 16; i++) {
pinMode(LEDPin[i], OUTPUT);
}
}
void loop() {
for(int j = 0; j < 14; j++) {
ShowPattern ( Pattern1[j]);
delay(500); // delay between frames
}
// Strobe
for(int j = 0; j < 14; j++) {
ShowPattern ( Pattern2[j]);
delay(500); // delay between frames
}
// Strobe
for(int j = 0; j < 8; j++) {
ShowPattern ( Pattern3[j]);
delay(500); // delay between frames
}
// Strobe
}
void ShowPattern(int Frame){
int mask = 1;
for(int i=0; i<14; i++){
if((mask & Frame) == 0) digitalWrite( LEDPin[i], LOW); else digitalWrite(LEDPin[i], HIGH); // Function, which reads binary sequences bit by bit into output pins pin by pin
mask = mask << 1;
}
}
This is exactly, what I wanted, easy to understand, only one function reads all patterns, and creating patterns is straight forward frame by frame and easy to understand. It does not need additional library, as the one I found above, so, I will probably stick to this one...
But, again and again, thanks to both of You - two days ago I had no faith I can do it myself and only expected to find something ready and adjust for my needs.
Any suggestion how to play melody in background?