The particle-field and particle-particle interactions induced by alternating electric fields can be conveniently used for on-chip assembly of colloidal crystals. Two coplanar electrodes with a millimeter-sized gap between them are used here to assemble two-dimensional crystals from suspensions of either latex or silica microspheres, When an AC voltage is applied, the particles accumulate and crystallize on the surface between the electrodes. Light diffraction and microscopic observations demonstrate that the hexagonal crystal is always oriented with one axis along the direction of the field. The particles disassemble when the field is turned off, and the process can be repeated many times. The diffraction patterns from all consecutively formed crystals are identical. This assembly is driven by forces that depend on the electric field gradient, and a model is proposed involving a combination of dielectrophoresis and induced dipole chaining. The organization of large two-dimensional crystals allows characterization of the electrostatic interactions in the particle ensembles. The process can be controlled via the field strength, the frequency, and the viscosity of the liquid media. It could be used to make rudimentary optical switches or to separate mixtures of particles of different sizes.