We propose a distributed algorithm to realize an automatic function alternation among sensor nodes. With this algorithm, the function of a damaged sensor node is dynamically taken over by a neighboring sensor node in order to maintain the initial functionality of a wireless sensor network. Each sensor node calculates an indicator value that represents the node's suitability as a candidate to alternate the function of the damaged node. By exchanging this indicator value with other neighboring nodes, the sensor node with the largest indicator value actually takes over the function of the damaged node. In this paper, after describing the function alternation algorithm, an application for sensing function alternation is introduced along with some evaluation results. Simulation results show that our algorithm can maintain a balanced distribution of sensing functions even when some sensor nodes are damaged.