Wrong reading of voltage by analog pin

I made a circuit to measure voltage across a resistor. Drawing 5v from arduino 5v pin, Connected it to two 1kΩ resistor in series. It should read 2.5v across the resistor or something near to that but it read 0.09 volts. I tried changing the resistor but still got the same
This is my code and circuit

Screenshots of code are nearly wortless. Read the how to get the best from the forum post to see instructions on how to post code and ask a question.

A hand drawn, photographed and posted schematic would be more helpful than a photo.

do NOT do pinMode(readPin, OUTPUT);

2 Likes

Does your voltmeter show ~2.5V at the analog in?

1 Like

Just run the analog input example code , lots wrong with I can see in your code ..
The two resistors wired in series - one end to 5v , centre to analog pin , other end to 0v .

1 Like

In the IDE Edit - copy for forum

then post your code.

1 Like

Help us help you.

......................................................................

1 Like

What code?

I thought you were being sarcastic, just predicting that the code is a nightmare or something, then I noticed the pictures of the monitor with some text and it looks like code, like when they show it on CSI or NCIS just there as decoration, scrolling up gently or not, you can tell it's code by the Autoformat format that it is in that hackers always are careful to use (IDE Tools menu BTW) and sometimes these days freeze it and see it is! Maybe real code.

Is that the code you all are talking about?

a7

It's hard to tell what you are doing from what you have posted, but since you changed the resistor and got the same value you are probably measuring on the low side which is basically measuring ground.

1 Like

Thanks y'all for helping!!!. Seems like I set A1 as output instead of output. Now it works. And yes I will take care abour how to post a problem here. Actually i'm new to this forum, so i didn't know about it before.

In your post you say this is your code…

Quote” tried changing the resistor but still got the same
This is my code and circuit“

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