Pages: [1]   Go Down
Author Topic: arduino reads only values from 0 to 500  (Read 654 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

it's the first time I use the arduino and I've connected a membrane potentiometer (http://www.spectrasymbol.com/typo3/site/en/softpotsplash/how-it-works.html). Ground is connected with one of the outer pins of the poti, 5V with the other outer pin, between this connection ist integrated a resistor of 1KOhm. The middle Pin is connected to Pin  2. Now the Arduino software gives me values from 0 - 500, when I press the potentiometer. But I measurd the voltage at the input Pin and it's 0 - 5 V. So there has to be values in the software from 0 - 1023, or not?
Another problem is that the arduino software gives random values for the case when I'm not pressing down the poti because the circle is open then, and the arduino gets no value. Is there a solution in programming it? (for example: the arduino gives 0, if there is no input).

Thanks for help, sorry for my bad english, I hope you understood my problem,
janas
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33432
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Use a pull down resistor of about 100K from the input to earth should stop it from giving random numbers when not pressed.

Not sure why you are not getting the full range especially as you are measuring the right voltage change on the input.
Logged

Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 507
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can also use the internal pull-up to cause it to read 5 V when nothing is connected (a good test would be to enable this pull-up and perform an analog read to see if you get 1023).  The internal pull-up is only around 20k or 30k, I believe, so it might influence your analog readings more than a 100k pull-up to ground or Vcc.

- Ben
Logged


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33432
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure you can enable a pull resistor when a pin is in the analogue mode? You can't on other processors I have seen.
Logged

Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 507
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Analog mode actually has no effect on the pin on the mega168, all it does is multiplex the pin voltage to the ADC module.  You can even use the pin as a digital output while reading its analog voltage (it's just that the result is not typically very exciting when you do this, unless you trying to drive high while shorted to ground or vice versa).

Note that if you're sure you want to use a pin as an analog input only you can manually disable its ability to be used as a digital input using the DIDR0 (Digital Input Disable Register).  The PIN value for the disabled input will always read zero, regardless of the voltage on the pin.  Doing this decreases power consumption of the digital input buffer.

- Ben
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
thank you for your help. I hoped, that there is a software-solution, something like that: if there's no signal give me 0. It would be better for me because I want to use the values in flash and 0 would be better than 1023. But it will work, too.
Thanks,
janas
Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
[snip informative reply]

- Ben
You really are an endless fount of useful information. :-) Thanks for your continued contributions to the Arduino community.

--Phil.
Logged

Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 507
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

And thank you for your thanks; it means a lot to me!

- Ben
Logged


Pages: [1]   Go Up
Jump to: