Staring and Stopping a timer using Accelerometer GY-61

Hi guys,

I am currently working on a project that gives feedback to the user on how much time they have spent sewing.

This requires a timer to start and stop when the needle starts and stops. I am achieving this by using an accelerometer (GY-61) on the needle.

I know that there will be two zero readings during the reciprocating cycle, but this time will be so minute that it won't matter. I did think about taking reading when the motor was running/ not running, but due to the current circumstances, I don't have the resources to do this so measuring the movement from the needle seems best.

My question: How do I get it so that when there is acceleration in the y-axis from the accelerometer the timer starts. And when there is no acceleration the timer stops? (I'm thinking it should be a call routing but I am new to coding so I would really appreciate some guidance on where to start.)

With Arduino we can save the time since startup in an unsigned long variable using millis() and later on subtract that start time from the current millis() value to see how long it has been.

I'd suggest saving start time with the first needle move (you could have done that way cheaper BTW) and not end the interval until the needle hasn't moved for a whole second or more, longer than a pause to turn or straighten something out.

There are many tutorials (usually with code) on the web/youtube and doesn't that board have examples to lift code from?