Figure 4—The main routine waits for a button press or incoming serial activity while taking measurements at regular intervals.