We present a distributed control strategy that lets a swarm of satellites autonomously form a lattice in orbit around a planet. The system, based on the artificial potential field approach, proposes a novel way to split the artificial field in two main terms: a global artificial field that gathers the satellites around a predefined meeting point, and a local term that allows a satellite to place itself in the correct position relative to its closest neighbors. We apply the method to the problem of forming a two dimensional hexagonal lattice, using the well-known Lennard-Jones potential as local artificial field. The control parameters have been obtained with a genetic algorithm to maximize the precision of the formed lattice. The precision does not depend on the number of satellites and convergence is achieved from all initial distributions of the satellites.