[SOLVED} Help with photoresistor into voltage

I have been having significant issue getting my photo resistor to work, with the eventual goal being creating a neo-pixel nightlight. Hoping to get some help. I've decided to take a few steps back and focus entirely on getting the voltage readings first which I seem incapable of doing. Am I just being stupid or what? I keep getting strings of random broken symbols and don't know why. Thanks!


void setup() {
Serial.begin(115200);

}


void loop() { 
  
 int reading; 

float voltage;

reading = analogRead(A5);      

voltage = reading*(5.0/1023.0); 


Serial.print(reading);    
Serial.print("  ");
Serial.println(voltage);  
}

Breadboard


Do you have the same baud rate in your sketch and in your computer???
(115200)
If you have a bad cable or a long cable you might try slower baud rates (9600)

Your code is set to 115200 baud, but your serial monitor is set to 9600. Change it to 115200 and it should be fine. If it doesn't work, your board might not be compatible with 115200 baud.

1 Like

Your code is using analogue pin A5 to read the voltage on the photoresistor, but you have it connected to digital pin 5.

Move your yellow wire to the pin arrowed below:
This is A5
..and adjust the baud rate as mentioned in posts #2 and #3.

1 Like

Also the connections to the breadboard are wrong too.

You have the three items that you want to connect together all on row A - there is no connection between them.

They all need to be on the same numbered column.

1 Like

Thank you so much! I had had it working earlier and wasn't able to figure it out.

If your question has been answered to your satisfaction please mark the thread as solved so that other members that may want to help will not waste time opening the thread only to find the question has been answered.

Make sure these wires do not touch each other. Otherwise you will burn the voltage regulator chip in your Arduino

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