Detecting time on a sensor

Hi there i am connecting a flex sensor to esp32 firebeetle board and wanted to know if there was a way in which I can time how long the sensor has been flexed and send a print after 45 mins of it being flexed continuously? I was thinking the use of millis but not sure if that would work.

Any help is much appreciated.

When you say "flexed" do you mean continuously flexed back and forth, or just simply no longer flat?

If the latter, use the idea shown in the state change detect example in the ide, to detect when it stops being flat and again when it's back to being flat. Use millis() to log the time at which both of those changes occur.

yes i mean when it is no longer flat. How would I go about logging the time that the changes occur, sorry to sound stupid I'm very new to all this.

Have a look at the state change detection example in the ide: File > Examples > 2 Digital if my memory serves.

The example's for a switch, so it's looking for high and low; you have an analog sensor so you'll need to apply your mind to how you would do that for analog values.

Then when you can detect a change from flat to flexed or flexed to flat, capture millis() into 2 variables say becameFlexedAt and becameFlatAt or similar.