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.
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