Interrupt problem.

Hi guys,
Sorry if this is the wrong forum or if this question has been asked previously. I’ve been scratching my head for a couple of days now on this one with no luck in searching for any answers to a similar problem.

So here it is. I’m trying to get a momentary button to change what patterns I’m using in a music visualizer I have made. I’m trying to do this using an interrupt to run through a switchcase. I’ve had this work on previous projects and even cross referencing them I can’t see where I’m going wrong.
I’d be over the moon if anybody here can help.

Here’s the code.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <FastLED.h>

#define DATA_PIN 1
#define CLK 2
#define LED_COUNT 100
#define bright 240
#define sensitivity 0.25 // 0.01 - 0.2


//AUDIO//
const int myInput = AUDIO_INPUT_LINEIN;
AudioInputI2S          audioInput;         // audio shield: mic or line-in
AudioAnalyzeFFT1024    myFFT;
AudioOutputI2S         audioOutput;        // audio shield: headphones & line-out
AudioConnection patchCord1(audioInput, 0, myFFT, 0);
AudioControlSGTL5000 audioShield;


//LEDS//
struct CRGB leds[LED_COUNT];


//INTERRUPT//
int int0 = 3;
volatile int state = 0;


void setup() {
 
  AudioMemory(12);

  audioShield.enable();
  audioShield.inputSelect(myInput);
  audioShield.volume(0.5);
 
  myFFT.windowFunction(AudioWindowHanning1024);
 
  attachInterrupt(int0,butStateChange,CHANGE);

  LEDS.addLeds<WS2801, DATA_PIN, CLK, RGB>(leds, LED_COUNT); 

for(;;) {
    switch (state){ 
    case 0: {
     bars();
    }
    break;
    case 1:{ 
     square();
    }
    break; 
    }
  } 
}

void loop(){
 
}

void butStateChange()
{
  static unsigned long last_interrupt_time = 0;
  unsigned long interrupt_time = millis();
  // If interrupts come faster than 200ms, assume it's a bounce and ignore
  if (interrupt_time - last_interrupt_time > 200) 
  {
    state++;
  }
  if (state >1){
    state=0;
  }
  last_interrupt_time = interrupt_time;
}

So here it is. I'm trying to get a momentary button to change what patterns I'm using in a music visualizer I have made. I'm trying to do this using an interrupt to run through a switchcase.

There is ABSOLUTELY no advantage of that vs. just polling the pin state.

Your code won't even compile, so we really can't help you.

  attachInterrupt(int0,butStateChange,CHANGE);

int0 is NOT 3.

My apologies Paul. It wasn't until I posted here and you pointed out my glaring mistake that it hit me. I now have it working. I feel a little stupid now though, thanks for pointing it out anyway.

Much appreciated.

Chris