Counting relay

Hi,
I'm new and I would like to know how I can do to count the number of time the relay work on digital pin ( for example Pin12).
And after use this information to command one servo.
Thanks to answer me.
Jean-Luc

I would like to know how I can do to count the number of time the relay work on digital pin ( for example Pin12).

The relay does not work on it's own. You must call digitalWrite() to set that pin HIGH or LOW. After setting the pin to the appropriate state, it should be obvious that adding

numberOfTimesPinHasBeenSet++;

will count the number of times that the pin has been set/the relay has been activated.

Of course, you need to declare the variable correctly, to.

And after use this information to command one servo.

After what? What is the relationship between the number of times that the relay has been activated and the position of the servo? What kind of servo is it?

Hi Paul Thanks for your quick answer,
When the relay will be use 10 times,I would like to use this information to move 180 degrees servo from 90 to 45.
And after 10 times again to move from 45 to 135 degrees.
At las 1O times so 30 times in total from 135 to 180 and 0 degrees.
Thanks for your help and see ya