Solved: Code Help !!

so have a set of void functions that do something and in a separate void function I want to have the parameters of the function stay the same just the name to change

void letters_H(int value,char c)
{
String colors = " ";
switch (c)
{
case 'B':
colors = "blueleds";
break;
// there are more in this switch statement just saving space 
}
// colors must be able to change to redleds or greenleds via the switch statement 
colors(1,value+12);
}

I keep getting an error, what am I doing wrong?
any help or a point in the right direction would be grateful.

I keep getting an error,

Is it a secret?

What's the error you get?

sorry yeah the error is …" No match for call to ‘(string)(int,int&)’ "

void letters_H(int value,char c)
{
String colors = " ";
switch (c)
{
case ‘B’:
colors = “blueleds”;
break;
// there are more in this switch statement just saving space
}
// colors must be able to change to redleds or greenleds via the switch statement
colors(1,value+12);
}

Is there a function called colors in the rest of the code?

jonny5: so have a set of void functions that do something and in a separate void function I want to have the parameters of the function stay the same just the name to change

Oh? I don't understand that statement. What name?

jonny5: // colors must be able to change to redleds or greenleds via the switch statement colors(1,value+12);

I don't understand the comment, nor do I understand what that line of code is trying to do. Can you explain what you think it is doing?

It's really better that you not have functions and variables with the same name. Function names should reflect what they actually do. colors() doesn't tell us squat about what the function does. Even something as simple as UseColors() is a better choice.

What function?

This reproduces the error message, almost:

void setup ()
{
String colors = " ";
colors(1,2);
}

void loop () {}

Gives:

sketch_dec05a.cpp: In function 'void setup()':
sketch_dec05a.pde:-1: error: no match for call to '(String) (int, int)'

Looks like he retyped the message, so what he said above isn't necessarily what it actually said.

Or if not, how about posting the whole code and not just tiny snippets?

ok so yeah i get it im not good at the code part but what im trying to say is…I have a bunch of functions that call different LED colors via shift registers and well what i want to do instead of hole bunch of code id rather have a function that has a switch statement in which takes the String colors which == “blueleds” and int C++ code it should theoretically be under stood as blueleds instead of colors by the microcontroller.
here is all the code im using to make this happen…
Every thing works and will scorll text just fine and display fancy colors.!!

int latchpin = 11; // Pin 12 ST_CP Storage Clock
int clockpin = 10; // Pin 11 SH_CP Shift Register Clock
int datapin = 12; // Pin 14 DS Data Input

void setup()
{
  pinMode(latchpin, OUTPUT);
  pinMode(clockpin, OUTPUT);
  pinMode(datapin, OUTPUT);
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);   
  digitalWrite(latchpin, HIGH);
}

void allwhiteleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  digitalWrite(latchpin, HIGH);
}

void allredleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000); 
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  digitalWrite(latchpin, HIGH);
}

void allgreenleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void allblueleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void allyellowleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  digitalWrite(latchpin, HIGH);
}

void allpurpleleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  digitalWrite(latchpin, HIGH);
}

void allcyanleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void whiteleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[9] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[9] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void redleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[9] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[9] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]); 
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void greenleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void blueleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void yellowleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void purpleleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void cyanleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127          };
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1          };

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void clearmatrix() 
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);

}

void randomleds()
{
  int R = random(9);
  int C = random(9);
  int Rvalue[9] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[9] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void letterH(int value, char c)
{
  String color;
  color = " ";
  switch (c)
  {
    case 'W':
    color = "whiteleds";
    break;
    case 'R':
    color = "redleds";
    break;
    case 'G':
    color = "greenleds";
    break;
    case 'B':
    color = "blueleds";
    brake;
  }
  color(1,value);
  color(2,value);
  color(3,value);
  color(4,value);
  color(4,value+1);
  color(4,value+2);  
  color(5,value);
  color(6,value);
  color(7,value);
  color(1,value+3);
  color(2,value+3);
  color(3,value+3);
  color(4,value+3); 
  color(5,value+3);
  color(6,value+3);
  color(7,value+3);
}

int value1 = 5;

void loop()
{
 // letterH(8);
 // greenleds(8,8);

  for(int count = 0; count < 10; count++)
   {
   letterH(value1,'B');
   //delay(1000);
   if (value1 == 0)
   {
   value1 = 8;
   }
   }
   
  delay(30);
  value1--;
  clearmatrix();
}

this is what part im trying to configure to do this so i can chose my color of text.

void letterH(int value, char c)
{
  String color;
  color = " ";
  switch (c)
  {
    case 'W':
    color = "whiteleds";
    break;
    case 'R':
    color = "redleds";
    break;
    case 'G':
    color = "greenleds";
    break;
    case 'B':
    color = "blueleds";
    brake;
  }
  color(1,value);
  color(2,value);
  color(3,value);
  color(4,value);
  color(4,value+1);
  color(4,value+2);  
  color(5,value);
  color(6,value);
  color(7,value);
  color(1,value+3);
  color(2,value+3);
  color(3,value+3);
  color(4,value+3); 
  color(5,value+3);
  color(6,value+3);
  color(7,value+3);
}

You can't call a function using its name. The compiler has removed, from the hex file, any evidence that the function even had a name.

You can create an array of function addresses, and call the appropriate function, by referencing the appropriate array index.

I have a bunch of functions that call different LED colors

How do you “call” a colour?

and int C++ code it should theoretically be under stood as blueleds instead of colors by the microcontroller.

Can you review that string of words and reform it into an understandable sentence please?

ok when void loop() executes letterH(value1,‘B’); its sent to the void function called void lettersH(int value, char c) and since variable c at this moment in time is equal to the letter ‘B’ to the switch statement in the void function called void letterH(int value, char c); color = “blueleds” and there for color(1,value); would be under stood to the microcontroller as blueleds(1,value) and light up a blue led on my matrix. but that dose not work

What's wrong with

switch (c)
  {
    case 'W':
    whiteleds(1, value);
    break;
    case 'R':
    redleds(1, value);
    break;
  }

and so on?

hey dxw00d i can do that but that's allot of code cause its printing out a letter not just one pixel if you will, it would look sorta like this....

void letterH(int value, char c)
{
  String color;
  color = " ";
  switch (c)
  {
    case 'W':
  whiteleds(1,value);
  whiteleds(2,value);
  whiteleds(3,value);
  whiteleds(4,value);
  whiteleds(4,value+1);
  whiteleds(4,value+2);  
  whiteleds(5,value);
  whiteleds(6,value);
  whiteleds(7,value);
  whiteleds(1,value+3);
  whiteleds(2,value+3);
  whiteleds(3,value+3);
  whiteleds(4,value+3); 
  whiteleds(5,value+3);
  whiteleds(6,value+3);
  whiteleds(7,value+3);
    break;
    case 'R':
  redleds(1,value);
  redleds(2,value);
  redleds(3,value);
  redleds(4,value);
  redleds(4,value+1);
  redleds(4,value+2);  
  redleds(5,value);
  redleds(6,value);
  redleds(7,value);
  redleds(1,value+3);
  redleds(2,value+3);
  redleds(3,value+3);
  redleds(4,value+3); 
  redleds(5,value+3);
  redleds(6,value+3);
  redleds(7,value+3);
    break;
    case 'G':
  // and so on 
    break;
    case 'B':
   // and so on ..........
    brake;
  }
}

Ah I see where you are coming from now.

OK, we can make that happen slightly differently, but pretty close. First make a new tab in the IDE (button on top RH corner) and give it the name “functionheader.h”. Then copy and paste this line into it:

typedef void (*ColorFunction) (int R, int C);

Now if you change your main sketch slightly to read like this, it compiles:

#include "functionheader.h"

int latchpin = 11; // Pin 12 ST_CP Storage Clock
int clockpin = 10; // Pin 11 SH_CP Shift Register Clock
int datapin = 12; // Pin 14 DS Data Input

void setup()
{
  pinMode(latchpin, OUTPUT);
  pinMode(clockpin, OUTPUT);
  pinMode(datapin, OUTPUT);
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);   
  digitalWrite(latchpin, HIGH);
}

void allwhiteleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  digitalWrite(latchpin, HIGH);
}

void allredleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000); 
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  digitalWrite(latchpin, HIGH);
}

void allgreenleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void allblueleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void allyellowleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  digitalWrite(latchpin, HIGH);
}

void allpurpleleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  digitalWrite(latchpin, HIGH);
}

void allcyanleds()
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B11111111);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void whiteleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[9] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[9] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void redleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[9] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[9] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]); 
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void greenleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void blueleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void yellowleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void purpleleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void cyanleds(int R, int C)
{
  if(R >= 9 || C >= 9)
  {
    R = 0;
    C = 0;
  }
  int Rvalue[] = {
    255,254,253,251,247,239,223,191,127          };
  int Cvalue[] = {
    0,128,64,32,16,8,4,2,1          };

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);
}

void clearmatrix() 
{
  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  shiftOut(datapin, clockpin, MSBFIRST, B00000000);
  digitalWrite(latchpin, HIGH);

}

void randomleds()
{
  int R = random(9);
  int C = random(9);
  int Rvalue[9] = {
    255,254,253,251,247,239,223,191,127};
  int Cvalue[9] = {
    0,128,64,32,16,8,4,2,1};

  digitalWrite(latchpin, LOW);
  shiftOut(datapin, clockpin, MSBFIRST, Rvalue[R]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  shiftOut(datapin, clockpin, MSBFIRST, Cvalue[C]);
  digitalWrite(latchpin, HIGH);
}

void letterH(int value, char c)
{
  ColorFunction color;
  switch (c)
  {
    case 'W':
    color = whiteleds;
    break;
    case 'R':
    color = redleds;
    break;
    case 'G':
    color = greenleds;
    break;
    case 'B':
    color = blueleds;
    break;
    
    default:
    return;  // no function chosen
  }
  
  color(1,value);
  color(2,value);
  color(3,value);
  color(4,value);
  color(4,value+1);
  color(4,value+2);  
  color(5,value);
  color(6,value);
  color(7,value);
  color(1,value+3);
  color(2,value+3);
  color(3,value+3);
  color(4,value+3); 
  color(5,value+3);
  color(6,value+3);
  color(7,value+3);
}

int value1 = 5;

void loop()
{
 // letterH(8);
 // greenleds(8,8);

  for(int count = 0; count < 10; count++)
   {
   letterH(value1,'B');
   //delay(1000);
   if (value1 == 0)
   {
   value1 = 8;
   }
   }
   
  delay(30);
  value1--;
  clearmatrix();
}

Virtually the only change I made (apart from changing “brake” to “break”, heh) was a slight change to the letterH function, as follows:

void letterH(int value, char c)
{
  ColorFunction color;
  switch (c)
  {
    case 'W':
    color = whiteleds;
    break;
    case 'R':
    color = redleds;
    break;
    case 'G':
    color = greenleds;
    break;
    case 'B':
    color = blueleds;
    break;
    
    default:
    return;  // no function chosen
  }
...

This isn’t tested, and I haven’t looked over the rest of the code. You can’t assign a string to a function (eg. color = “whiteleds”) but you can assign a pointer, as I have done above.

that works!!! you think i need to have it be in a header file, can't i just paste that in my main code?

That works, I didn't think it would. Just make the first few lines of the main file:

typedef void (*ColorFunction) (const int R, const int C);

int latchpin = 11; // Pin 12 ST_CP Storage Clock
int clockpin = 10; // Pin 11 SH_CP Shift Register Clock
int datapin = 12; // Pin 14 DS Data Input

And then you can get rid of the .h file.

BTW you should probably make those const, it might help the compiler generate smaller code:

typedef void (*ColorFunction) (int R, int C);

const int latchpin = 11; // Pin 12 ST_CP Storage Clock
const int clockpin = 10; // Pin 11 SH_CP Shift Register Clock
const int datapin = 12; // Pin 14 DS Data Input

yeah thank you i took what you gave me and put

typedef void (*ColorFunction) (const int R, const int C);

at the top of my code.
and then in my void letteH(int value, char c) at the top of my switch i put your other line of code

void letterH(int value, char c)
{
  ColorFunction color;
  switch (c)
  {
    case 'W':
    color = whiteleds;
    break;
    case 'R':
    color = redleds;
    break;
    case 'G':
    color = greenleds;
    break;
    case 'B':
    color = blueleds;
    break;
    
    default:
    return;  // no function chosen
  }

and walla it worked like a charm

rgb_leds.txt (8.93 KB)