We propose a cellular automaton based local algorithm to reposition mobile sensors of a wireless sensors network. Our main goal is to maximize the total coverage of the network while maintaining the connectivity among the sensors. In most of the applications, it is not feasible to deploy mobile sensors using a global algorithm. Typically, the sensors are initially densely deployed and use their mobility to increase the coverage of the network. Our algorithm uses very limited local information to compute the final positions of the sensors. In many applications, maximizing the coverage is not the only objective; the sensors also need to communicate with each other. Therefore, maintaining connectivity when the sensors disperse is an important goal, and our algorithm achieves this as well. We perform different simulations on different starting configurations. For some configurations, the optimal solution is arrived at, while for others a near optimal solution is obtained.