Audio Shield / FFT / Push Button / Interrupts

Status
Not open for further replies.

rexhex

Member
Hello Forum members,

I am working on a project that is using the audio shield with FFT. At the moment I am working on cycling through different settings with two push buttons set as external interrupts. The buttons are working fine but the FFT stops working when I add them to the code. I was thinking that FFT uses interrupts and by turning a pin into an interrupt for the button its messing the the FFT. Does anyone know what pins are used as interrupts for the FFT with the audio shield? The pins I currently have as push button interrupts are 9 and 17.

Thank you for you time,

Rex
 
Glad you found the problem.

In general, the Bounce library is usually best for pushbuttons. It automatically handles mechanical chatter, which can play havoc with interrupts. All the audio tutorials with pushbuttons use the Bounce library, so there's plenty of code in File > Examples > Audio > Tutorial to follow as examples.
 
I like the bounce library because it makes coding for a push button easy. The reason I started to get into interrupts is that my code is gaining many functions and steps. It would take a while for the program to see when a button was pressed. I am handing the debounce with the quoted code. So far this seems to be working great.

void push1()
{
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
if (interrupt_time - last_interrupt_time > 400){
buttonChange1++;
if (buttonChange1>=5){buttonChange1 = 1;}
}
last_interrupt_time = interrupt_time;
Serial.print("PUSHED button 1 ==");
Serial.println(buttonChange1);
}
 
Status
Not open for further replies.
Back
Top