The electronic structure of the CuO(x) planes is studied using a gener
alized Hubbard model including Cu-O repulsion U(pd), for each value of
x and two different assumptions on the oxygen (O) ordering. The resul
t explains qualitatively the experimentally observed hole count in the
CuO2 planes, the amount of Cu+ and the metal-insulator transition nea
r x=0.5. For large enough U(pd) the energy DELTAE favoring ordering in
chains is positive. A simple explanation of this and the relation bet
ween charge transfer and O ordering is given. The screening length lam
bda is calculated using Thomas-Fermi theory, an effective one-band mod
el for the CuO2 planes and experimental data. This information is used
to construct an effective lattice-gas model for the O ordering, based
on O-O screened repulsions in which DELTAE is the only parameter. The
superstructures predicted by this model by this model provide an expl
anation of almost all observed diffraction patterns,and of recently, o
bserved photoinduced changes in the transport properties. The electron
ic and structural results are consistent with the observed dependence
of the superconducting T(c) vs x.