Go Down

Topic: 16*16 led matrix help (Read 579 times) previous topic - next topic

6v6gt

If you have now wired the switches so that they are now connected between ground and the corresponding arduino pins, you should have this:


Code: [Select]

. . .
pinMode(button_a, INPUT_PULLUP); // If button pressed, digitalRead() == LOW otherwise it is HIGH.
pinMode(button_b, INPUT_PULLUP); // If button pressed, digitalRead() == LOW otherwise it is HIGH.
// no digitalWrite() statements are needed.
. . .
. . .

  // if button_a is pressed, store it
  if (stateA == LOW) {
    stored_state [last_x][last_y] = true ;
  }

  // if button_b is pressed, delete it
  if (stateB == LOW) {
    stored_state [last_x][last_y] = false ;
  }

. . .
. . .



I guess this code should be as follows because storedState[ ] [ ] uses indexes 0 to 15 so should correct the problem you have described where only the first matrix  appears to be used for store/recall :
Code: [Select]

  if ( (last_x != x_translate) || (last_y != y_translate) )
  {
    // the position has moved so we need to restore previous state
    if ( last_x < 8  && last_y < 8 )  lc.setLed(0, last_x,     last_y,     stored_state [last_x][last_y] );
    if ( last_x >= 8 && last_y < 8 )  lc.setLed(1, last_x - 8, last_y,     stored_state [last_x][last_y] );
    if ( last_x < 8  && last_y >= 8 ) lc.setLed(2, last_x,     last_y - 8, stored_state [last_x][last_y] );
    if ( last_x >= 8 && last_y >= 8 ) lc.setLed(3, last_x - 8, last_y - 8, stored_state [last_x][last_y] );
  }





rrowley

#16
Feb 09, 2019, 03:24 pm Last Edit: Feb 09, 2019, 03:25 pm by rrowley
Fantastic.That works perfectly.I've learned quite a lot looking at how you've altered the original code so thanks again

6v6gt

OK. Good. I'm pleased that about that. Now it works, you can explain what it is. Is it a game or what ?

rrowley

It's going to be the display of an audio switching matrix where the leds will indicate which switch is closed.I'm using the adg1414 octal switch.It seems pretty easy to control via spi.The hard part for me now is linking the status of a stored led to a closed switch on the adg1414

Something like this

6v6gt

Oh great. I'm glad it has a practical application and the display does look good.

Go Up