Flex sesnor not reading if else statement

Hello Arduino Community,
I am here for some help with my flex sensor. I am using a flex sensor to give me values from A0 and using those values in my If Else Statement. my last else statement doesnt want to run and I've tried to make another else if statement and that doesnt help either. Anyone got any pointers or advice? Ive also attached my code below.

`
int ledPin_1 = 10;   //pin 3 has PWM funtion
int ledPin_2 = 11;   //pin 3 has PWM funtion
int ledPin_3 = 9;   //pin 3 has PWM funtion
int ledPin_4 = 6;   //pin 3 has PWM funtion
int ledPin_5 = 2;
int ledPin_6 = 3;
int ledPin_7 = 5;
int analogValue =1;
int flexPin = A0; //pin A0 to read analog input
int threshold = 529;

//Variables:
int value; //save analog value


void setup(){
  
  pinMode(ledPin_1, OUTPUT);//Set pin 3 as 'output'
  pinMode(ledPin_2, OUTPUT);
  pinMode(ledPin_3, OUTPUT);
  pinMode(ledPin_4, OUTPUT);
  pinMode(ledPin_5, OUTPUT);
  pinMode(ledPin_6, OUTPUT);
  pinMode(ledPin_7, OUTPUT);
  Serial.begin(9600); //Begin serial communication
  pinMode(flexPin, INPUT);
  
  
}

void loop(){
  
  analogValue = analogRead(flexPin);         //Read and save analog value from potentiometer
  Serial.println(analogValue);               //Print value
  value = map(value, 700, 900, 0, 255);//Map value 0-1023 to 0-255 (PWM)
  delay(1000);
  /*
  int analogValue = analogRead(flexPin);         //Read and save analog value from potentiometer
  Serial.println(analogValue);               //Print value
  analogValue = map(analogValue, 700, 900, 0, 255);//Map value 0-1023 to 0-255 (PWM)
  analogWrite(ledPin_1, analogValue);
  delay(1000);   //Small delay
  */


    

  if ( analogValue > 601) {
      digitalWrite(ledPin_1, HIGH);
      digitalWrite(ledPin_3, HIGH);
      digitalWrite(ledPin_6, HIGH);
      digitalWrite(ledPin_5, HIGH);
      digitalWrite(ledPin_2, HIGH);
      digitalWrite(ledPin_7, LOW);
      digitalWrite(ledPin_4, LOW);
      delay(1000);

      
      
  }
  else if((analogValue <= 600) && (analogValue >= 530)) {
     digitalWrite(ledPin_4, HIGH);
      digitalWrite(ledPin_7, HIGH);
      digitalWrite(ledPin_5, HIGH);
      digitalWrite(ledPin_6, HIGH);
      digitalWrite(ledPin_3, HIGH);
      digitalWrite(ledPin_1, LOW);
      digitalWrite(ledPin_2, LOW);
      delay(1000);
  }
    else {
 
     digitalWrite(ledPin_7, HIGH);
    delay(1);
    digitalWrite(ledPin_5, HIGH);
    delay(100);
    digitalWrite(ledPin_6, LOW);
    digitalWrite(ledPin_3, LOW);
    digitalWrite(ledPin_1, LOW);
    digitalWrite(ledPin_2, LOW);
    digitalWrite(ledPin_4, LOW);

    digitalWrite(ledPin_7, LOW);
    digitalWrite(ledPin_5, HIGH);
    delay(100);
    digitalWrite(ledPin_6, HIGH);
    delay(10);
    digitalWrite(ledPin_3, LOW);
    digitalWrite(ledPin_1, LOW);
    digitalWrite(ledPin_2, LOW);
    digitalWrite(ledPin_4, LOW);

    digitalWrite(ledPin_7, LOW);
    digitalWrite(ledPin_5, LOW);
    digitalWrite(ledPin_6, HIGH);
    delay(100);
    digitalWrite(ledPin_3, HIGH);
    delay(100);
    digitalWrite(ledPin_1, LOW);
    digitalWrite(ledPin_2, LOW);
    digitalWrite(ledPin_4, LOW);

    digitalWrite(ledPin_7, LOW);
    digitalWrite(ledPin_5, LOW);
    digitalWrite(ledPin_6, LOW);
    digitalWrite(ledPin_3, HIGH);
    delay(100);
    digitalWrite(ledPin_1, HIGH);
    delay(100);
    digitalWrite(ledPin_2, LOW);
    digitalWrite(ledPin_4, LOW);

    digitalWrite(ledPin_7, LOW);
    digitalWrite(ledPin_5, LOW);
    digitalWrite(ledPin_6, LOW);
    digitalWrite(ledPin_3, LOW);
    digitalWrite(ledPin_1, HIGH);
    delay(100);
    digitalWrite(ledPin_2, HIGH);
    delay(100);
    digitalWrite(ledPin_4, LOW);
       
    digitalWrite(ledPin_7, LOW);
    digitalWrite(ledPin_5, LOW);
    digitalWrite(ledPin_6, LOW);
    digitalWrite(ledPin_3, LOW);
    digitalWrite(ledPin_1, LOW);
    digitalWrite(ledPin_2, HIGH);
    delay(100);
    digitalWrite(ledPin_4, LOW);
    delay(100);
  }

 }

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Hum do you see a problem ? :thinking:

So since the flex sensor value stops reading at 200, the other variables that are >=530 are not being considered?


Serial.println(analogValue);

What is the analogValue range printed on the serial monitor ?


Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring. Give links to components.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.