simple switch and LED code problem

Hello,

The purpose of the simple code below is to read the value of 2 input switches. If there value is equal to each other, an output LED should be active (other wise not). But if I run the code on the controller, the output LED is active at all the 4 combinations of the switches (so even when they are different to each other). Can somebody (quickly as possible) give me a hint where my problem is hidden? thx alot!

int ADR1 = 0; //switch 1 on A0
int ADR2 = 1; //switch 2 on A1
int LED = 13; //LED std on arduino 13
int ADR1_Value;
int ADR2_Value;
int ADR1_State;
int ADR2_State;

void setup() {
pinMode(ADR1, INPUT);
pinMode(ADR2, INPUT);
pinMode(LED, OUTPUT);
}

void loop(){
ADR1_Value = analogRead(ADR1);
ADR2_Value = analogRead(ADR2);

if (ADR1_Value > 1000)
{ADR1_State = HIGH;}
else {ADR1_State = LOW;}

if (ADR2_Value > 1000)
{ADR2_State = HIGH;}
else {ADR2_State = LOW;}

if(ADR1_State == ADR2_State)//
{digitalWrite(LED, HIGH);
delay(1000);}
else {digitalWrite(LED, LOW);}
}

Add Serial.begin() to setup(). Add Serial.print() statements to loop(). Find out what you are actually reading from the analog pins.

I'd guess that you never actually get a value over 1000 from either pin, so you really only have one state, with the LED on.

Not a lot of point setting the pinMode for analogue inputs. Not a problem, just a bit of a waste of program space and typing.

@ PaulS : thx for the tip. I saw that I've get a value above 1000 (for example 1050) for a high state switch and a value below (for example 600) for a low state, so my tresholds where right but I've seen the problem now : every time I've change the value of 1 of the switches, I have to re-upload the program so that only then the controller updates his inputs and outputs. Strange that it doesn't constantly repeat itself (when it is in "void loop ()" :). @ AWOL : the reason for analog reading the switch inputs is that this is just a simple test for general reading the inputs of switches. Later I will read 6 switches (ideal the 6 analog inputs from the controller) with a whole lot of other digital inputs and outputs and will use the max. 20 I/O's of the controller.

every time I've change the value of 1 of the switches, I have to re-upload the program so that only then the controller updates his inputs and outputs. Strange that it doesn't constantly repeat itself (when it is in "void loop ()

Something is wrong, then. What kind of switches do you have connected to the analog pins? How are they wired? What does your code look like now? Inquiring minds (aka busybodies) want to know.

Problem with setting ADR1 and ADR2 to be inputs is that they're the serial interface pins