Reed switch understanding

I've been struggling with a reed switch all day. I'm going to eventually be doing some fancy stuff with it, but wanted to make sure I could read it. I copied the code and scheme straight from the button tutorial--http://www.arduino.cc/en/Tutorial/Button to use, but using a reed switch instead of a button.

Problem is, it wouldn't work right at all. I was trying pulling high, low, and tempted to try somewhere in between. :stuck_out_tongue: I've been messing around with a multimeter to make sure the voltages were right were they were supposed to be. It started working when I put the voltmeter between the 5V source, and the high side of the switch. LED came on, and the switch is controlling it properly now.

Any ideas as to what the problem was? I'll be moving on to other things, but this might come up again, and I'd like to know how to avoid the problem in the future.

Possibly a bad connection. I have a bread board where some of the holes refuse to make a connection unless I bend the wire a certain direction.

Can you provide a picture of your circuit setup ? Like Jassper said, some bad wiring somewhere. Also it depend what type of reed switch you have. They work like a relay. Need a transistor to switch them. The contact is simply an ON / OFF switch.

I think this one is a little fuzzy, I’ll try again with a better camera later.

This is a switch by the way, not a relay. It provides input–specifically, it’s intended to be screwed onto a door or window to provide an open/closed signal to whatever. I’m actually using it to help setup a different program, but getting the setup for that was important.

reed switch setup001.jpg

This is a switch by the way, not a relay. It provides input--specifically, it's intended to be screwed onto a door or window to provide an open/closed signal to whatever.

Now I understand the situation. The "reed" swtich is one of those "magnetic switche" use in an alarm system.

I am assuming you have a magnet to test the circuit.

First. Test the reed switch with a ohm meter. ← disconnected from the circuit.
Second. Connect the reed like any on/off switch.

+5 ----- 1 k resistor — any digital pin ----- the reed switch ---- gnd

in code :

           pinMode(reed, INPUT);
           the_switch_status = digitalRead(reed);
           // the_switch_status : contact ON = 0 - LOW
           //                            contact OFF = 1 - HIGH