arduino analog returns offset value after accident

539 views Asked by At

I am painfully new to arduino so keep that in mind, while experimenting with a volt meter sketch with a resistor divider (100k and 10k resistor) then I tried to connect a 5v power supply (regulated off board) I doubt it was the voltage due to the divider but I do not know about the current. what i didn't realize was I had not powered it on and got the infamous smell I the quickly disconnected it. after that i tried testing it again (this mainly took place on the analog 0 pin) the board seems to function fine except for the analog pins they will now read ~200 and will not work correctly in my other programs like a ohm meter this could be normal i don't know but i do know that it is not working anymore so any explanation is appreciated

when i say its not functioning i mean my sketches aren't working but it might help you to know my (not exactly mine) sketch

int analogPin= 0;
int raw= 0;
int Vin= 5;
float Vout= 0;
float R1= 1000;
float R2= 0;
float buffer= 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
raw= analogRead(analogPin);
if(raw) 
{
buffer= raw * Vin;
Vout= (buffer)/1024.0;
buffer= (Vin/Vout) -1;
R2= R1 * buffer;
Serial.print("Vout: ");
Serial.println(Vout);
Serial.print("R2: ");
Serial.println(R2);
delay(1000);
}
}

so when i test it with the intended circuit from here by default (no resistor) it returns around 3900 and when i attach a 330 resistor i get 3500
so overall can applying that is in the firts part damage the analog pins functionality and if not what couldve happend and if i can fix it i hope that covers everything if i am forgetting something let me know
thank you

ps i am aware of other questions with returning wrong values but they do not answer any of my questions so please be accommodating

0

There are 0 answers