Analog pins not working

I have setup the Photoresistor project and have been pulling my hair out all day. It seems no matter what I have plugged into the analog pins, I get random values ranging from around 800 - 1400. Doesn’t matter if I have nothing plugged in, the reading changes randomly. If I use a resistor or photoresistor it makes absolutely no difference.

Dying over here…

Hi @NickTheGreek

If you leave the analog inputs undriven, you will get random values. If you connect the inputs to a voltage, like a resistor divider using a photo resistor and another resistor, you should get values that are consistent within a few percent.

Maybe your circuit is not wired up correctly?

There was a piece of cardstock with pinouts that told me where to put everything. I have the resistor connected from ground to A0, and the photoresistor connected from A0 to A5. Reading pin A5.

And here’s my code:

int photoresistor = A0;
int power = A5;
int analogvalue;

void setup() {
pinMode(photoresistor,INPUT);
pinMode(power,OUTPUT);
digitalWrite(power,HIGH);
Particle.variable(“analogvalue”, &analogvalue, INT);
}

void loop() {
analogvalue = analogRead(photoresistor);
delay(100);
}

Now it’s only reading: 4095

Hi @NickTheGreek

Reading 4095 is good! Do you have the other fixed resistor (borrow it from the LED side) that you can replace the photo resistor with? That should make the reading go to 2047.

I tried that and it still says 4095

Try removing this line--there have been some problems with this interfering with the setting used for analogRead (which is not INPUT). The line as your have it configures A0 as a digital input.