Passing a threshold twice

Hi all,

I'm trying to take a measurement of variable x only after an event (variable y) has occurred two times.

In my case, variable x is pitch and y is acceleration (not worried about equations for these)

How would I construct code to do this? I realize I probably need a for loop and some boolean terms with if statements, but I can't seem to figure it out how to even get started.

Cheers

Count how many times y has happened and set a boolean variable to true when it has happened the required number of times. Make the execution of the code to measure x dependant on the boolean being true.

No for loop needed. Put the code in loop() and it will repeat the y reading. You may want to stop the y reading or set the counter to zero once x has been read. That is up to you.