need help for Interrupts

i using MAX7219 to drive 8x8 matrix, below is the code for filling matrix, i am trying to interrupt the program with button and start from where it interrupted.
like play pause.

void loop()
{

for(int row=0;row<4;row++) {

for(int col=0;col<8;col++) {
delay(100);
lc.setLed(0,col,row,true);

}
}
}

Determine how you would like to use an interrupt to read a button and write an isr for it.

Your max7219 code remains unchanged.

  1. post your code in code tags.

  2. You do not have a problem with interrupts because you are not using them. I can't see any calls attachInterrup() or ISR()! Interrup has a very specific meaning in software!.

  3. You do have a problem with your code seeing the button being pushed, this is because of your use of delay()!

Start over, after looking at "blink with out delay".

Mark

i try this but it break code.

#include "LedControl.h"
LedControl lc=LedControl(10,9,8,1); 

int keypress ;
const int buttonPin = 3; 
void setup()  
{ 
  pinMode (buttonPin, INPUT);
  pinMode(2, INPUT);
  attachInterrupt(0, pause,CHANGE); 
  lc.setIntensity(0,8);
  lc.shutdown(0,false); // need to take MAX out of shutdown
  lc.clearDisplay(0);  
  delay(10);
}  

void loop()  
{ 
  
  for(int row=0;row<4;row++) { 

    for(int col=0;col<8;col++) { 
      delay(100); 
      lc.setLed(0,col,row,true); 
      if(keypress==1){ 
        break;
        
      }
    } 
  }        
        keypress = 0;
   
  lc.clearDisplay(0);

}

void pause()
{
  keypress = 1;
 }

i try this but it break code.

How?

int keypress ;

Variables used in both interrupt service routines and in regular functions MUST be declared volatile.

  for(int row=0;row<4;row++) { 

    for(int col=0;col<8;col++) { 
      delay(100); 
      lc.setLed(0,col,row,true); 
      if(keypress==1){ 
        break;
        
      }
    } 
  }

You only want to break out of the inner loop?

Isyourspacekeybroken?