  We propose and work out a scheme to generate the entangled W states for a
chain of N four-level atoms which are transported through an optical cavity by
means of an optical lattice. This scheme is based on the combined laser-cavity
mediated interaction between distant and equally separated atoms and works in a
completely deterministic way for qubits encoded by two hyperfine levels of the
atoms. Only two parameters, namely the distance between the atoms and the
velocity of the chain, determine the effective interaction among the atoms and,
therefore, the degree of entanglement that is obtained for the overall chain of
N qubits. In particular, we work out the parameter regions for which the W
states are generated most reliably for chains of N = 2,3,4 and 5 atoms. In
addition, we analyze the sensitivity in the formation of entanglement for such
chains of qubits due to uncertainties produced by the oscillations of atoms in
optical lattices.
