Controlled doping of perovskite semiconductors can tune their electrical conductivity and enable switching between positive and negative charge carrier conduction.