LED in line of input

Hello!
I am trying to give a digital input to an Arduino Nano through a 3 pin reed switch. When the reed switch is deactivated, the pin is pulled to ground. When it is activated it is pulled to 5V. The pin I am using is an analog pin but in my code I have declared it as digital. Schematic is seen below. I am sorry for the poor drawing.

My problem is that, even though the input is registering that the switch is activated, the LED does not light up. I am not experienced and I searched for an answer as well as I could before posting.

Thank you for your time,

George

If you want the LED to light up when the pin is high the LED and resistor (1K is a bit high) need to be connected from the pin to ground.

Steve

Try this circuit:-

It pulls up normally and so reads a HIGH when the reed switch is open.
When the reed switch is closed the input reads low and the light lights up.
So the LED is lit when the switch is active.
If this is the wrong way round for your software then change the software. If your head can't cope with this then have these two lines at the top of your code:-
#define OPEN HIGH
#define CLOSED LOW

then:-

switch = digitalRead(pin);
if(switch == OPEN) // do switch open stuff
if(switch == CLOSED) // do switch closed stuff

As used in this project of mine :- Chaotic Pendulum

Should also set internal pull up on the pin in setup() with pinMode.

pinMode (reedPin, INPUT_PULLUP);

That gives the pin a well defined HIGH, eleminating the LED threshold voltage.
Leo..

Also, don't short 5V and GND.