To interupt or not to interupt? Using an MPU6050 as a trigger

Hi, I'm building a game where movement sets off an alarm. The amount of movement (i.e. sensitivity threshold) is specified at the beginning of the game.

I'm using an MPU6050 and have so far been using a loop to compare values and trigger the alarm when the threshold is crossed. It's proving difficult to stop it freezing, however, and I suspect it may be due to my Nano being overloaded.

My questions: 1. Would using interupts - as in the Jeff Rowberg code - be a better approach? Or is it a bad use-case? 2. Is the threshold for triggering the interupt adjustable? I've been searching for a long while and can't get my head around when it will be triggered, because the values have some natural fluctuation anyway. With a self-balancing robot, for example, surely the interupt is being fired constantly?

I've got hunch my conceptualisation is wrong somewhere, but would appreciate any pointers. Many thanks, Paul

pallen33: It's proving difficult to stop it freezing, however, and I suspect it may be due to my Nano being overloaded.

There is no way to overload a Nano, it will run if not powered down or sleeping, without complaints or knowledge about the things hopefully going on.

Interrupts are no solution for freezing code and add overhead.

You are showing no code, so I can not help you with your program.

Thanks for your reply. It was more the conceptualisation of interupts that I was looking for help with, rather than this specific issue of freezing i.e. how they are used when the data coming from a sensor has natural fluctuation.

(As an aside which may be useful for others, there does seem to be an issue with MPU6050 code and freezing that is discussed in this long thread, with posts by Jeff Rowberg himself. From my understanding, it's not actually solvable due to certain software / hardware constraints)

pallen33: It was more the conceptualisation of interupts that I was looking for help with, rather than this specific issue of freezing i.e. how they are used when the data coming from a sensor has natural fluctuation.

If you have not studied it, give www.gammon.com.au/interrupts a try.

Great, thanks, I'll give that a read

pallen33: (As an aside which may be useful for others, there does seem to be an issue with MPU6050 code and freezing that is discussed in this long thread, with posts by Jeff Rowberg himself. From my understanding, it's not actually solvable due to certain software / hardware constraints)

Link no worky.

This discussion may be useful. Scroll down to 'MCP23017 Interrupts Don't Work'.