Arduino library to execute a function every X times some condition has occurred