|Abstract: ||Methods are provided for forming a plurality of permanent magnets with two different north-south magnetic pole alignments for use in microelectromechanical (MEM) devices. These methods are based on initially magnetizing the permanent magnets all in the same direction, and then utilizing a combination of heating and a magnetic field to switch the polarity of a portion of the permanent magnets while not switching the remaining permanent magnets. The permanent magnets, in some instances, can all have the same rare-earth composition (e.g. NdFeB) or can be formed of two different rare-earth materials (e.g. NdFeB and SmCo). The methods can be used to form a plurality of permanent magnets side-by-side on or within a substrate with an alternating polarity, or to form a two-dimensional array of permanent magnets in which the polarity of every other row of the array is alternated.