Using electromagnets

Yes, I do mean PWM, and I will not be reversing polarity- in fact I was using a MOSFET with a function generator, zener diode and an external power source, but it wasn't doing what I needed; I need a digital on/off signal rather than a constant analog one. The function generator was actually causing the electromagnet to reverse its poles and generate an AC current which has been a bit frustrating to overcome. That's why I decided to turn to using a programable microprocessor configuration to generate the on/off signal. So far the arduino's been awesome, I've had my eye on it for simple robotics applications for a while, but I think it'll work great for this as well.

Thanks everyone for your quick responses and useful information.