Possible to add start/stop function

I have written a sketch that reads a water pressure transducer. It is used to read pressure during experiments... these experiments can last up to 2 hours. Is there a way to have Arduino constantly on and reading the transducer but have a "trigger" function to have it read and write out to a file only when I need it to? I don't want to be dealing with unnecessary data but I still want to see it on the serial plotter.

Thanks!

Here's the current sketch:

int S1Pin = A1; // Sensor 1 is connected to pin A1

// the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); }

// the loop routine runs over and over again forever: void loop() { // read the input on analog pin 1: int sensorValue = analogRead(S1Pin); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(sensorValue);

delay(10); // Pauses the program for the amount of time (in milliseconds) specified as parameter. (There are 1000 milliseconds in a second.) }

Yes. Presently you always output the sensorValue. // print out the value you read: Serial.println(sensorValue);

Instead put the println inside a conditional statement so that thevalue is onlyprinted when the condition is met e.g. if the value exceeds a certain limit.

You might want to alos print the time so that you know when the event occurred.