0

analog input
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

analog input

by phasic on Wed Sep 23, 2009 1:40 pm

I have an Arduino Duemilanove. Im running a scetch where it reads analog values from pin 0 to 5 on the analog set. Dont know if there is something wrong. When I attach a potentometer to pin 0 and the other terminal to 5V it only displays 1023 on the screen no matter how I turn the potentometer. Ive tried this with others. I know its worked before. I also run other projects on the board.
phasic
 
Posts: 3
Joined: Wed Sep 23, 2009 1:28 pm

Re: analog input

by TheDon125 on Wed Sep 23, 2009 2:05 pm

You need to ground one end of the potentiometer, attach the other end to 5V, and attach the wiper to the arduino analog input.

The way you described your setup, you effectively have only a variable resistance between the analog input and 5V. Since there is a negligible current flowing (for this application), there is no voltage drop across the resistor, and so the voltage will be 5V. What you want to create is a voltage divider circuit, where the potentiometer actually varies R1 and R2, and the analog voltage read is the output of the divider. A potentiometer naturally does this, with R1 being the resistance between the 5V terminal and the wiper, and R2 being the resistance between the wiper and the grounded terminal.
TheDon125
 
Posts: 23
Joined: Tue Jan 09, 2007 9:58 pm

Re: analog input

by zener on Thu Sep 24, 2009 3:25 am

What he said.

The pot then forms a "voltage divider", which is a very important concept you should learn about. It is used all the time for different things. Here is a very complicated explanation:

http://en.wikipedia.org/wiki/Voltage_divider

It is fairly simple once you get the idea.

zener
 
Posts: 4445
Joined: Sat Feb 21, 2009 2:38 am

Please be positive and constructive with your questions and comments.