Hi TMFOH,
Could you tell me, are you running the whole system off the 12v power pack?
When it is working are you running it off the USB port to power it?
Reason for asking is i womder if you are overloading your 12v with the electromagnet?
How much current does it draw?
May be on the wrong track here dut if this sounds like it then try disconnecting the electromagnet and running your circuit without it.
Reason i say this is i see you marked your power pack as 12v 0.42A or 420mA which would not be unreasonable for an electromagnet to draw that or more.
Daz