mr. gerivega
Thank you very much for your suggestion. Currently the program works partially correctly. But there is a problem as below. After the Arduino is energized, it can only open and close the relay once when the program runs.
The algorithm I want the program to run is as follows.
-Recording on the sd card should start with the character from the voltage or serial and the relay counter should work at the same time. After 15 seconds the relay should be HIGH and after 500ms remaining on it should be LOW again. The recording still continues. Until a character comes from the serial. If a character comes in, the recording stops.
-If a character comes back or the voltage is read, the loop should start all over again.