The invention relates to a heavy metal detector with switching function and good detection effect. The heavy metal detector comprises a base, a protective cover, a switching mechanism and a cleaning mechanism, the switching mechanism comprises an isolation plate, a glass plate, a housing, a conveyor belt, a conductive component, a second motor, two rotating rollers, at least two hollow cathode lamps and at least two contacts, the cleaning mechanism comprises a guide rail, a moving seat, absorbent cotton, a driving component and two supporting components, wherein the conductive component comprises a sliding rod, an elastic sheet, two first springs and two moving sleeves, in the heavy metal detector with a switching function and a good detection effect, the switching between the hollow cathode lamps can be achieved through the switching mechanism, so that the heavy metal detector can detect different elements, the working efficiency of the heavy metal detector is improved, the glass plate can be cleaned through the cleaning mechanism, the decay of the energy of the hollow cathode lamps can be weakened, and the detection effect of the heavy metal detector can be improved.