Go Down

### Topic: analogRead(analogPin); always returns 1023 (Read 7247 times)previous topic - next topic

#### Fennec

##### May 04, 2011, 05:28 am
I have  6 1k resistors in parallel and no matter where in the chain I take a reading with analogRead(analogPin) it will return 1023.

I noticed another post.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1294203579

I followed the tests.

Connect the analog input to GND.  Do you get a rock-solid zero from analogRead?
YES

Connect the analog input to +5 V.  Do you get a rock-solid 1023 from analogRead?
Yes
and it Does not matter I will always get 1023 when it is connected to either +5 or anywhere in the 6 1k resister chain.

Any ideas.

By the way I am using a Modern Devices BBB.

#### rbtying

#1
##### May 04, 2011, 07:15 am
If you've a bunch of resistors in parallel, my first instinct tells me you've got one side of the resistor at +5v and another at 0v - thus why you would always measure 5v at the ADC.  Try putting a pair of them in series: (+5v resistor resistor 0v) and measure the junction between the two resistors - it should form a voltage divider and give you an ADC value around 512 (if the resistors are equal in value).

#### nickgammon

#2
##### May 04, 2011, 07:50 am

I have  6 1k resistors in parallel and no matter where in the chain I take a reading with analogRead(analogPin) it will return 1023.

With 6 resistors in parallel you can only measure in two places. One end or the other end. Do you mean series? In which case is one end connected to ground, and the other to 5V? And what is the sketch exactly?
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

#### hugo007

#3
##### May 04, 2011, 11:41 am
hello
this is a common error you are making.For what I understand you are conecting resistors to the 5 V rail and the conect it directly to the analog input right?
If this is your case the analog port will always give you the value of 1023 because at other side of the resitors are 5 V!! since you dont conect it to the ground!!!
You can test it with a multimeter and you will see there are 5 V there independently the value of the resistor , even with a resitor 1M you will get 1023!!! (soo arduino is right)
you must reference the other side of the resistor to make a voltage drop in the midle of the 2 resitors , like a potenciometer , or a voltage divider.Then you conect the analog port on the midle of the 2 resistors and you will see the value will change on arduino

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

#### Fennec

#4
##### May 04, 2011, 03:06 pm
Sorry my Mistake. I am using the resistors in series.

I am using this sketch:  http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1226896251

I was just looking at that post and noticed I needed to connect them to ground like this.

analogPin                 +5 V
*      |                         |
*      |                         \
*      ----------------          /
*                     |          \    .5K
*                     |          /
*                     |          \
*                     |____ \____|
*                     |   SW1    |
*                     |          \
*                     |          /
*                     |          \    .5K
*                     |          /
*                     |          \
*                     |____ \____|
*                     |   SW2    |
*                     |          |
*                     |          \
*                     |          /
*                     |          \    .5K
*                     |          /
*                     |          \
*                     |____ \____|
*                     |   SW3    |
*                     |          |
*                     |          \
*                     |          /
*                     |          \    .5K
*                     |          /
*                     |          \
*                     |____ \____|
*                     |   SW4    |
*                     |          |
*                     |          \
*                     |          /
*                     |          \    .5K
*                     |          /
*                     |          \
*                     |          |
*                     |____ \____|
*                         SW5    |
*                                |
*                                |
*                              _____
*                               ___     ground
*                                _

So I connected the end to ground and Now get the various readings I should have been getting. It was my mistake to not connect to ground. I had printed it out and the end of that diagram was a little mangled.

Thank for the help and ideas pointing me at the correct solution.

Go Up