The invention relates to a dual-purpose 
piezoelectric generator, and belongs to the technical field of 
new energy. Two cross beams are arranged on the outer side of the right wall of a 
body cavity ofa main body, wherein lug plates at the two ends of an 
inertia body are connected with the cross beams of the main body through reeds, and a main 
magnet is mounted on the 
inertia body through an adjusting block; an end cover is mounted at the upper end of the 
body cavity, the two ends of a guide pin are arranged in a counter bore of the end cover and a counter bore of the bottom wall of the 
body cavity respectively, and the guide pin is sequentially sleeved with a 
balance spring, an 
exciter and a buffer spring from bottom to top; two or two sets of cams are symmetrically arranged on the left side face and the right side face of the 
exciter, and an auxiliary 
magnet is mounted on a protruding block in the center of the right side face of the 
exciter; the 
cam surface is composed of a bottom face, an inclined face and a top face which are sequentially connected; seat plates with inclined mounting faces are mounted on the 
left wall and the right wall of the body cavity, piezoelectric vibrators are mounted on the mounting faces and are of 
cantilever beam structures formed by bonding base plates and piezoelectric pieces, ejection blocks are mounted at the free ends of the piezoelectric vibrators and abut against the 
cam surface, and when no interaction force exists between the main 
magnet and the auxiliary magnet, the ejection blocks make contact with the middle points of the inclinedfaces of the cams.