Help whit arrays and functions!

Hello!
I have problem to get my program to work. I know how to make simple things like using one array and one function but in this example i can't make em to work together :frowning: .
I shall control 22 different leds and they shall change color and after a certain amount of time.

This is the values a want to use, it's the values to make one rgb led to be red.
Maybe it's easier to separate each led..

int redColor [6] = {4000,0,0,4000,0,0};

This is channels on my tlc5940. channel 1-3 is one rgb led for example and 4-6 is led nr2.
Maybe it's easier to separate each led..

int slooperLeds[6] = {1,2,3,4,5,6};

This how i'am trying to give led nr1 a red color. a-b-c is where i give the color values, and z-x-y is the pin numbers.

  Tlc.set(x, a);
  Tlc.set(y, b);
  Tlc.set(z, c);

I have been trying many different things and do not remember all, but i have "//" some of em, i hope u guys don't i am stupid after seeing them but i have been trying around.

#include "Tlc5940.h"
int redColor [6] = {4000,0,0,4000,0,0};
int slooperLeds[6] = {1,2,3,4,5,6};
//int redColor = (4000,0,0,4000,0,0);
//int sloopersLeds = (1,2,3,4,5,6);

//  ---------------------------------------------- Beginning of setup
void setup() { 
Tlc.init();
}
// ----------------------------------------------- End of setup

// ----------------------------------------------- Beginning of loop
void loop() {
Tlc.update();
// sloopers = redColor[6]{0,1,2,3,4,5}, sloopersLeds = [6]{0,1,2,3,4,5};
// sloopers = redColor[6]{[0],[1],[2],[3],[4],[5]}, sloopersLeds = [6]{[1],[2],[3],[4],[5],[6};
// int sloopers = slooperLeds,redColor;  
sloopers = slooperLeds,redColor;  
Tlc.clear();
delay (1000);
}
// ----------------------------------------------- End of loop

// ----------------------------------------------- Function led 1-2
void sloopers (int x,int y,int z, int x2,int y2,int z2, int a, int b, int c , int a2, int b2, int c2); 
{
  
  Tlc.set(x, a);
  Tlc.set(y, b);
  Tlc.set(z, c);
    
  Tlc.set(x2, a2);
  Tlc.set(y2, b2);
  Tlc.set(z2, c2);
}
// ----------------------------------------------- End of function led 1-2

read this Demonstration code for several things at the same time - Project Guidance - Arduino Forum

Mark

holmes4:
read this Demonstration code for several things at the same time - Project Guidance - Arduino Forum

Mark

Thx mark i am going to wire it up and go true the code, it's a bit complicated to just read for me :slight_smile:

Delta_G:
Since those arrays are global, you don't need to pass them to the function. The function can take zero arguments. What you do need to do is quit writing random shit and go learn how to access the elements in an array and how to properly call a function. You can look at any C++ tutorial on the internet. Google "C++ arrays" and "C++ functions"

Thank u Delta_G, Yes i know! But this "shit" :slight_smile: is fucking hard, for me this is 100 times harder to understand than change valves on my car or build a house from scratch. I know i am going to fast into this but i am collecting puzzle parts and when i have some it's easier for me to understand and "see the light".

This is what my code loks like now.
error
'sloopers' was not declared in this scope

#include "Tlc5940.h"

int slooperLeds[3] = {1,2,3};
int redColor [3] = {4000,0,0};

//  ---------------------------------------------- Beginning of setup
void setup() { 
Tlc.init();
}
// ----------------------------------------------- End of setup

// ----------------------------------------------- Beginning of loop
void loop() {

Tlc.update();
sloopers();
Tlc.clear();
delay (1000);

}
// ----------------------------------------------- End of loop

// ----------------------------------------------- Function led 1

void sloopers(); 
{
  
Tlc.set(slooperLeds[0], redColor[0]);
Tlc.set(slooperLeds[1], redColor[1]);
Tlc.set(slooperLeds[2], redColor[2]);

}
// ----------------------------------------------- End of function led 1