[SOLVED} Issue with photoresistor readings

Hey yall. Trying to get a photoresistor to work and I can't seem to make any progress, it only seems to detect max voltage. Any signs of where I'm going wrong in the breadboard or in the code. The later code isn't finished yet but it shouldn't effect it as it revolves around received readings.

#include <Adafruit_NeoPixel.h>   
#define NEOPIXELPIN    11    
#define NUMPIXELS      5    
Adafruit_NeoPixel pixelStrip  = Adafruit_NeoPixel(NUMPIXELS, NEOPIXELPIN, NEO_GRB +
NEO_KHZ800);


// ----------------------------------------------------------------¬
void setup() {
    pixelStrip.begin();       


    
    Serial.begin(9600);
    
}


// ----------------------------------------------------------------¬
void loop() {





  
int reading; 


float voltage;


reading = analogRead(A5);       


voltage = reading*(5.0/1023.0); 





if (voltage<2.0) {
  
  Serial.print(voltage);
  Serial.print(" ");
  Serial.println("Dark turn on all pixels");


} else if (voltage>2.3 && voltage<=4.3) {
Serial.print(voltage);
Serial.print(" ");
Serial.println("Low light, turn on pixels to a pleasant color");


}else{ 
  Serial.print(voltage);
Serial.print(" ");
Serial.println("Bright enough, turn off all pixels");
}
}



The produced readings are as follows

Your purple wire is connected to the wrong leg of the photoresistor.

It wants to connect to the junction of the photoresistor and the resistor.

1 Like

For heavens sake, delete the empty lines. My scrolling finger aches and the eyes are orbiting.

Thank you, It's working properly now!

Rude

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