How to make a magnetic switch