Can I run two function in arduino simultaneously?
You can imagine a program as a procedure that a CPU executes, reading and doing step by step.
When you compile any program, the compiler checks it, and when it finds some error it can tell you exactly where (the line) in which you made this error.
It can be done simply because the program is a series of commands.
Also if, in some cases (interrups, callbacks, asynchronous functions etc.), it seems to be different, the code is always executed step by step, like when you follow a recipe when you're cooking.
You don't have to worry about that, in fact these steps are done by the CPU very quickly and you can do many things as they would be done seemingly simultaneously.
The Arduino Uno (Atmega328) works at 16Mhz.
As you can read here: &quot;an almost empty loop() is seen about 150k times a second&quot;.
So don't worry about the simultaneity of your functions.
You can write a function for detecting the earthquake that calls other functions (like alarms, procedures, etc.) without much time lapse (the best logic I think is: first check the event, then do stuffs).
The only thing I suggest you do is to reduce the code to let it become as small (and fast) as possible, but we are talking about a few milliseconds of lapse from earthquake to alarm.
If you need to register the exact time of the earthquake (absolute precision) you can use the micros() command.
In this case remember to do that as the first instruction (to reduce delay, of course).