Serial Port not working properly

i'm trying to look at the Monitor tab but when I do it says serial port unavailable for a bit then it starts working but just keeps saying '1023', i'm not sure what to do, does anyone know how to help?



We'll deal with the "serial port unavailable" part of the question in PixelMaker06's other thread:
https://forum.arduino.cc/index.php?topic=626121

This thread can be exclusively about the "keeps saying '1023'" issue.

@PixelMaker06 I guess you didn't bother to read the "How to use this forum" post as I requested in your other thread. If you had done so, you would have learned the correct way to post code on the forum. Posting screenshots of text is extremely unhelpful and will make it much less likely for you to get assistance here. You also forgot the other thing I requested you to do, which was to describe your circuit.

(deleted)

sorry, here's my code in text:

int LDR = A0;

void setup() {
pinMode(LDR,INPUT);
Serial.begin(9600);
}

void loop() {
Serial.println(analogRead(LDR));
delay(200);
}

my curcuit is one ldr with a resistor connected to 5v gnd and A0, please help, I am new to this and can't find anything online.

(deleted)

Did you try

put a jumper wire in pin A0 and connect it to GND, does the value change to 0?

my curcuit is one ldr with a resistor connected to 5v gnd and A0

That does not really explain how things are connected. Please draw a pencil and paper diagram, photograph it and post the 'photo here

Here's my code:

int LDR = A0;

void setup() {
    pinMode(LDR,INPUT);
    Serial.begin(9600);
}

void loop() {
   Serial.println(analogRead(LDR));
   delay(200); 
}

I have attached photos of my setup.
My problem is that whenever I go to Monitor all it displays is 1023 over and over again no matter what lighting there is.





@PixelMaker06, please do not cross-post. Threads merged.

sorry, when i posted befor people told me that i had posted at the wrong bit and stuff like that so i posted again doing what they asked.

@UKHeliBob @spycatcher2k when i put A0 to ground it did display '0'

(deleted)

Hi,
I think you need to use this connection;
Note S is Signal, - is gnd, + the centre pin is +5V.


Just move the signal wire to A0 from A2 as in your code.
Tom.. :slight_smile:

Thank you, I figured it out, as @TomGeorge pointed out, my ldr was different from the one on the website I used so the pin configuration was different. Thank you all!

(deleted)