Hi, I wasn't sure whether this should go in 'Project Feasibility' or 'Programming Questions', but it deals entirely with programming so I figured I would put it here.
I'm using the Arduino IDE with an Adafruit Circuit Playground Express microcontroller to build a proof-of-concept for an engineering class I'm in. To make a long story short, what I'm attempting to do is to sample accelerometer data from the microcontroller and use the 'arduinoFFT.h' library to analyze its frequency spectrum.
This has worked perfectly thus far, but what I would like to do is be able to 'reanalyze' the data every two seconds or so, while still using all the data from the past ten seconds. The problem is that the FFT library that I use takes about 240ms to complete a run, and I need to sample from the accelerometer every 20ms. So running the FFT analysis means losing out on 12 datapoints every 2 seconds, which will cause major artifacts in my spectrum.
I read online about timer interrupts and how they can be used to 'stop' what the microcontroller is doing to run a small script, but many sources tell me that I can't do things like read from an accelerometer within an interrupt routine.
Is there any alternative way to do this? What would be ideal is if it was possible for me to halt the FFT script when I need to sample data and then pick up from where I left off after the accelerometer data is written into an array. Does such a thing exist in Arduino programming?