analogRead loop not working

I am really not too big on coding, but I don’t understand why this code gives me 0 on the analogRead? While in any other way to do the loop it does work.


void ScanFootSensor(void) { 
int LegCounter;
int LegValue;
int LegSensor;
int SensorReactSpeed;
int SensorDeviationY;
bool LegUp;
void ScanFootSensor(void) {
LegCounter++;
if (LegCounter==5) LegCounter=1;
 // read the input on analog pin:
if (LegCounter==1) 
 int LegSensor = analogRead(A2);
if (LegCounter==2) 
 int LegSensor = analogRead(A3);
if (LegCounter==3) 
 int LegSensor = analogRead(A4);
if (LegCounter==4) 
 int LegSensor = analogRead(A5);

delay(1)
 LegValue=100;
if (LegSensor > LegValue) 
 LegUp=true;
else 
 LegUp=false;

 // print out the value on analog pin:
Serial.begin(38400);
Serial.print("LegNR:");
Serial.print(LegCounter);
Serial.print(" LegUp:");
Serial.print(LegUp);
Serial.print(":");
Serial.println(LegSensor);
 SensorReactSpeed=10;
if ((LegUp==true) && (SensorDeviationY<140)) {
 SensorDeviationY = SensorDeviationY + SensorReactSpeed;
}
else {
 if (SensorDeviationY>10)
  SensorDeviationY = SensorDeviationY - SensorReactSpeed;
}
}

Hi,

Could you please attach the project file to your post directly (maybe in a .zip)?

Sincerely,