How to run an "on-demand" program, how to save data, and how to set a run time?

Need help for a beginner on several related aspects Smile

  1. How to start the program only after entering the command?

    That is: the program throws out the text "To start press (X)" and waits with the execution of the rest of the program until you enter the appropriate character from the PC keyboard.

  2. How to stop the program at the appointed time?

    That is: Before starting, the program throws out the text "How long will the program last (in min)?". The time in minutes is given, entered from the keyboard and after the specified time the program stops the loop.

  3. How to store the data from the predetermined time in the memory and display it at the end?

    That is: the program has a timer implemented - it starts when the program starts. How to store and, after stopping the program (from point 2), display on the screen the values obtained in 5, 10, 15 etc. minutes?

Translated with DeepL Translate: The world's most accurate translator (free version)

void setup ()
  Serial.begin (115200);
  // More setup stuff . . . 
  Serial.println (F("Hit any key to start..."));
  while (Serial.available()== 0) ;

1 Like

:scream::scream::scream: that’s a bit harsh without an explanation ! XXX OOO

The rest of the answer can be found in the serial basics thread, and the good ol' blink-without-delay example.

There is no program that can be started or stopped in a normal Arduino C++ environment.

You can make the one running program wait for something or do something.

Do you planing to built a cocktail mixer?

Nope. It's a flow meter :slight_smile:

The device is to provide the following data:
measurement time,
flow at the moment
total flow.

Measurement time and flow are counted (program starts) after pressing any key.

Finally (after 60 minutes), the total flow for every 5 minutes of measurement should be displayed - e.g. 0min - 0l, 5min - 10l, 10min - 13l, etc.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.