Interrupts are used to run a specific function in the background. The way it works is that the interrupt uses takes control of the processor and performs its respective task and then returns control back to regular operations.

For example, imagine you have a girlfriend and a friend. The girlfriend has higher priority and is listed under the interrupt where as the friend has normal priority and is a part of the regular processor's work. So a practical example of this interrupt working is if you were talking to your friend of normal priority and your girlfriend calls, the interrupt is triggered and you hold the call with your friend and pick up the call for your girlfriend. You will continue this call until your girlfriend is done. After that call, you will continue your call with your friend.

Similarly, anything in a computer, whatever is in the interrupt is done first whenever the interrupt is called and the rest of the processes with normal priority will hold until the process in the interrupt is completed. You must watch out not to put too many heavy things in the interrupt or else the processor will never be able to complete normal priority processes.

In mbed, there is a default class built into mbed.h called Ticker. Ticker has many functions and sub-classes that will allow you to create many different types of interrupts. The normal Ticker object will allow you to make an interrupt that will trigger after a specified amount of time. The TimeOut class allows you to make an interrupt that will interrupt the processor for a certain amount of time and then terminate.

Use the following link as a source for these methods: https://developer.mbed.org/users/mbed_official/code/mbed/docs/252557024ec3/classmbed_1_1Ticker.html

NOTE: Higher sampling rate on the interrupt will increase the accuracy when measuring values from sensors such as an IMU.