Wireless sensor networks (WSNs) is taking an increasing role in our lives. Because the energy of the sensors is limited how to efficiently use the energy to prolong the lifecycle of the sensor networks is very important. In this paper, a novel energy-balanced dynamic routing algorithm based on ACO is proposed. The novel routing algorithm can dynamically choose routing according to the residual energy of the sensors and the sensors with more power is taken more data transfer tasks. The simulation results show that the proposed routing algorithm can effectively balance energy consumption and prolong the lifecycle of the networks.