I'm new to this forum, so hello to everyone out there.
So I have an Uno with A0 connected to the positive end of a chain of LEDs (they light up when a motion sensor goes off, clunky, but it works), and the negative end is hooked up to the GND of the analog side of the Uno. It runs the following code:
void setup()
{
Serial.begin(115200);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
}
void loop()
{
Serial.println(printVals(A0));
}
float printVals(uint8_t pin)
{
int sensorValue = analogRead(pin);
float voltage = sensorValue * (5.00 / 1023.00);
return voltage;
}
And when I open the Serial Plotter, I get a weird square wave for the voltage (when there is 0V on the LEDs, I used a volt meter). Out of curiosity, I added a jumper cable from A2 to +5V (the red wire in the diagram) and added plotting for A2, and this solved the problem - except now, the read on A0 is about 0.53.
Now, I'm more of a software guy, so I figure just subtract 0.53 and move on (varies only +- 0.03V), but I want to know: What in the world did that jumper cable do?