LDR sensor module on giving 1023 or 32 as output

My project is to make an automatic window blinds. I want to adjust the blinds according to the light level, but the LDR sensor module giving output of 1023 or 32 only depending upon the light. I want the mid values (values in between 1023 to 32) to rotate the window blinds slightly. I can only open or close them. Earlier, the sensor was working fine, detecting all the values, but now with the same connections its not giving correct values.

Here's my code below :

#define ldr A0
void setup() {
  // put your setup code here, to run once
  pinMode(ldr, INPUT);
  Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
    int val = analogRead(ldr);
    if(val >= 30 && val <= 50)
    {
      Serial.println("VERY BRIGHT");
    }
    else if(val >= 100 && val <= 150)
    {
      Serial.println("BRIGHT");
    }
    else if(val >= 200 && val <= 500)
    {
      Serial.println("DIM");
    }
    else if(val >= 500 && val <= 600)
    {
      Serial.println("LOW LIGHT");
    }
    else if(val >= 600 && val <= 900)
    {
      Serial.println("VERY LESS LIGHT");
    }
    else if(val >= 900 && val < 1023)
    {
      Serial.println("DARKER THAN BLACK HOLE");
    }
    //delay(1000);
}

My device : Arduino nano v3 328p Proccessor

Connections :
LDR GND - ARDUINO GND
LDR DO pin - ARDUINO A0
LDR VCC pin - ARDUINO 5v

If Vcc changes sensor values will likely change. Link to the datasheet please.
What is "correct value"? What values are coming?
Why check for values being between 30 and 50? Why not go for just below 50? Why is 29 exckuded?

only 32 or 1023 values are coming I want middle values like : eg 700 ,500 so that i can tilt the blinds more or less

1023 likely means a bad connection. Either the signal line is shorted to Vcc or the pull-down side of the voltage divider is open-circuit. Try a new light sensor module.

"DO" means "Digital Output". You need the other pin.

I just noticed that there are many cheap modules with only a digital output and not a analog output. What else do you have ? Resistors, LDR, multimeter ?

What value of pullup resistor are you using?

@Kopel has it correct, you are likely reading from the wrong output.
Those modules are usually dual purpose:

  1. Trigger high on a certain threshold on DO, adjustable by pot
  2. Send actual value on AO, which is what you want to read for your project

@Koepel I saw a setup video from YouTube. I have done all the connections according to it. Thanks for giving your time. I am using LDR for the first time.

Video links :

I really need all the values from 32. - 1023
I tried using the digital pin, but they show 0 in absense of light or 1 in presence of light.

The module that you have has only a digital output. There is a link under that Youtube video to the sketch on Github. That shows that a digital pin is used.

All you need is a resistor and a LDR.
Adafruit has the best tutorials: https://learn.adafruit.com/photocells

All you need is the bare LDR between analogue pin and ground, no resistor.
Then you can try this test sketch.
Leo..

const byte ldrPin = A0;
int ldrValue;

void setup() {
  Serial.begin(9600);
  pinMode(ldrPin, INPUT_PULLUP); // enable internal pull up
}

void loop() {
  ldrValue = analogRead(ldrPin);
  Serial.print("LDR value: ");
  Serial.println(ldrValue);
  delay(1000);
}