Controlling using IR remote to change Led display Matrix Patterns

Hello Anyone,
Need help Please on how to fix this sketch or sketches as to: "Control, using IR remote to change Led display Matrix Patterns".
I have the IR remote controller working so far and I have the 6x6 Matrix Display patterns as separate Sketch files 20 all together.
I think this would work together by using some type of String or Array. I will show what I have a example, please someone could you help me on this project thanks.
Russ...[cornell84@hotmail.com]

IR_Remote_Buttons_Cross.ino (4.29 KB)

artrjc:
Hello Anyone,
Need help Please on how to fix this sketch or sketches as to: "Control, using IR remote to change Led display Matrix Patterns".
I have the IR remote controller working so far and I have the 6x6 Matrix Display patterns as separate Sketch files 20 all together.
I think this would work together by using some type of String or Array. I will show what I have a example, please someone could you help me on this project thanks.
Russ...[cornell84@hotmail.com]

It is not at all clear what you are trying to do, or what you are asking. You're going to have to provide a whole lot clearer description - along with much more details - if you want help.

Thank you for responding to my Problems, First of all this is my second time writing this post letter in this forum. I know now to save anything I write to anyone. I should have saved it as a doc. or txt. File before sending it. You just can’t Pre-view it before sending it, so that the Arduino web site can’t lose it or drop out on me (lost in La’ La’ Land somewhere????).

Anyway what I would like to do is get my Arduino Uno Rev 3 to do the following:
I want to set up 20 different Patterns using my remote to control 20 Buttons to switch different Patterns
On my Led Matrix 6X6 dot display 6=Rows X 6=Cols.
I have 20 sketches that are all the same except for the String codes are different.
I have the IRremote control sketch working with my Hex codes for the 20 buttons to be used.

// Example sketch Name: Shift_Bowtie (Pattern #1)
// Note: using (2) 74HC595’s to control Rows & Columns.

int SER = 8;
int LATCH = 9;
int CLK =10;

int interval = 0; //how many millis to cycle between numbers

int firstdigit = 0; //integers to hold individual digit values
int seconddigit = 0;

//sequence of 0-10
int sequence[10] = {0, 97, 225, 30, 12, 0, 18, 18, 0};
//for diff. Patterns change numbers sequence .

void showvalues(int one, int two) //function to display values
{
unsigned long currentmillis = millis(); //store current millis
do {
digitalWrite(LATCH, LOW);
shiftOut(SER, CLK, MSBFIRST, sequence[one]);
digitalWrite(LATCH, HIGH);

unsigned long int x = millis() - currentmillis;
} while ((millis()-currentmillis) < interval);
}
void setup() {
Serial.begin(9600); //start serial if needed

pinMode(SER, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(CLK, OUTPUT); }

void loop() {
for (int i = 0; i < 999; i++) {
int b = i;
firstdigit = b % 10;
b = b/10;
seconddigit = b % 10;
showvalues(firstdigit, seconddigit);
}
}

artrjc:
Thank you for responding to my Problems, First of all this is my second time writing this post letter in this forum. I know now to save anything I write to anyone. I should have saved it as a doc. or txt. File before sending it. You just can’t Pre-view it before sending it, so that the Arduino web site can’t lose it or drop out on me (lost in La’ La’ Land somewhere????).

Anyway what I would like to do is get my Arduino Uno Rev 3 to do the following:
I want to set up 20 different Patterns using my remote to control 20 Buttons to switch different Patterns
On my Led Matrix 6X6 dot display 6=Rows X 6=Cols.
I have 20 sketches that are all the same except for the String codes are different.
I have the IRremote control sketch working with my Hex codes for the 20 buttons to be used.

// Example sketch Name: Shift_Bowtie (Pattern #1)
// Note: using (2) 74HC595’s to control Rows & Columns.

int SER = 8;
int LATCH = 9;
int CLK =10;

int interval = 0; //how many millis to cycle between numbers

int firstdigit = 0; //integers to hold individual digit values
int seconddigit = 0;

//sequence of 0-10
int sequence[10] = {0, 97, 225, 30, 12, 0, 18, 18, 0};
//for diff. Patterns change numbers sequence .

void showvalues(int one, int two) //function to display values
{
unsigned long currentmillis = millis(); //store current millis
do {
digitalWrite(LATCH, LOW);
shiftOut(SER, CLK, MSBFIRST, sequence[one]);
digitalWrite(LATCH, HIGH);

unsigned long int x = millis() - currentmillis;
} while ((millis()-currentmillis) < interval);
}
void setup() {
Serial.begin(9600); //start serial if needed

pinMode(SER, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(CLK, OUTPUT); }

void loop() {
for (int i = 0; i < 999; i++) {
int b = i;
firstdigit = b % 10;
b = b/10;
seconddigit = b % 10;
showvalues(firstdigit, seconddigit);
}
}

So you have exactly the same file, 20 times, except that you have different values in the array "sequence"? That's a truly awful way to do it. Any time you find yourself copy and pasting the same code over and over with only one or a few changes, it's a clue that you should be doing things differently.

In this case, I would suggest making your show values function take a pointer to the sequence array. Then you can define that method once, and simply invoke it using different sequence arrays.

You can define sequence1, sequence2, etc, and call the method using the appropriate sequence array. You could also create an array of arrays and loop through those, but I'm guessing that that is beyond your current abilities.

You may want to pick up a book on beginning C and do some studying. It would help a lot.

How would I make the values function take to a pointer in a sequence array.
Could you give me some example to do this?

You are right I'm new to this C++ and I'm just getting started with this new project.

How can I define that method once, and simply invoke it using different sequence arrays.
I think i can set up this part on defining sequence1, sequence2, etc, and call the method using the appropriate sequence array?

Creating an array of arrays and loop through those, but I'm guessing that is beyond your current abilities.(You are right about this area not sure how to do it).

Thanks
Russ....

Can you post one of your pattern sketches so we get a idea about how you're doing it?
Then we can tell you how to merge all your patterns into one sketch.
Better then doing everything over.

Yes I've got part of it working, but still having a hard time telling the IR remote controller buttons 1 -20 pointing to the String Array --- seq0[]={0,0,0,0,0,0,0,0,0,0}; thur seq19[]={0,0,0,0,0,0,0,0,0,0}; to display on my 6 X 6 LED Matrix.
I've tried to set up some type of control but not addressing right, just lights up 1 or 2 row of lights maybe 4 rows of leds light up no pattern to the array yet.
Thanks for any help you can give me, I need it still new at this Arduino Uno thing.
Russ....

IR_Remote_Buttons_work.ino (4.78 KB)

IRremote.h (3.8 KB)

void loop() {      
    for (int j = 0; j < 999; j++) {
    int b = j;
    one = b % 10;
    b = b/10;
    two = b % 10;
    showvalues(one, two);    <---------------display ?
    
 // IR remote Buttons 1-20 
  if (irrecv.decode(&results)) {
    switch (results.value)  {
      case 0xFF1AE5:// code in Hex 
        Serial.println("DGT 1");
        digit=1; 
        break;
      case 0xFF9A65:// code in Hex 
        Serial.println("DGT 2");
        digit=2; 
        break;
      case 0xFFA25D:// code in Hex 
        Serial.println("DGT 3");
        digit=3;
        break;
      case 0xFF22DD:// code in Hex

If your routine to display the patterns is showvalues(one, two);
Then in each IR case, just put in the values for one and two

at the end, after the last break;
call the display

        digit=18;
        break;

      case 0xFF58A7:// code in Hex 
        Serial.println("DGT 19");
        digit=19;
           one = 'whatever'   <-------------------pointers for patterns
           two = 'whatever'
        break;

      case 0xFFD827:// code in Hex 
        Serial.println("DGT 20");
        digit=20;
        break;     
     }
             showvalues(one, two);       <----------------------- show pattern, if that's what this is.

  irrecv.resume(); // Receive the next value
  }
}
}

Sorry, I don't have the proper set-up to test the code, so you will have to wing-it.
However, this should give you the general idea.

Maybe?
You could put the seq[]= in each case, since they are so short.