The simplest way to make an electromagnet is to get a solenoid, pass some current through it, and then get a piece of soft iron inside the solenoid. When the current is switched off, the electromagnet is no longer, well, magnetic!
What this means is that you just need to power this here electromagnet with about 5VDC (you don't have to be exact, 4-6V will work fine) and ka-pow, it's now a magnet. Turn off the power and it reverts back to a normal chunk of metal. Since its a coil, you'll need to use a motor or solenoid driver with kick-back protection. Our Crickit boards will work great.
Please note: electromagnets are specified with "holding force", say 2.5Kg / 5.5lb. This is not how much weight they can pick up! Divide the holding force by 5-10 to get a rough estimate of how heavy a thing it can pick up. So in this case, about 1 lb. Note that pick-up weight also depends on a flat surface and max surface contact, and the ferromagnetic metal content. A perfectly flat steel cube will work great, something oddly shaped or covered in rubber or plastic will not!
Documentation and Downloads