# Analog Inputs

If we had an analog input device hooked up to Analog Input Port 1, what would the value rc_ana_in01 represent? Is it the voltage? Or possibly (Voltage * 1024 / 5)?

Resistance is usally the value it looks at. I have minimal FIRST electircal experiance but normally this is whats looked at with analog.

rc_ana_in01 is a constant that you pass to GetAnalogValue in order
to read the corresponding analog input.

For example:
int analogvaluefrominput01;
analogvaluefrominput01 = GetAnalogValue(rc_ana_in01);

The resulting value stored in the int variable has the range 0 to 1023
0 corresponds to roughly zero volts, and 1023 corresponds to roughly
5 volts. Your equation reflects that.

Edit: The analog inputs on the RC look at voltage. When a POT is
hooked up to one these inputs it is wired as a voltage divider for a
5 volt supply. The analog inputs on the OI have a different range,
0 to 255(254), and are set up to jump to 127 in the event that 0 volts is
applied (or the circuit opens), for safety reasons.

Eugene

There is an upper and lower threshold to these voltages. I don’t remember exactly where they are but it is significantly different than 0 and 5V. Over the Upper Threshold you will get 1023. I think you get 0 below the Lower Threshold. Make sure you center any pots you are using so that the entire Range of Motion is in the significant voltage range.

ahh thanks I understand now

So for example…
The dual-axis accelerometer supplied in the kit has a sensitivity of 290mV per g (acceleration due to gravity) and a range of +/- 2g. So the accelerometer reports voltages in the range of 1.92 - 3.08, and Get_Analog_Value(rc_ana_in01) would return values in the range from 393 - 631. Then I can convert that number into units of g with…

``````
(Get_Analog_Value(rc_ana_in01) - 512) * 5.0 / 1024 / 0.290

``````

??

The correct function spelling is Get_Analog_Value() and it is defined in ifi_utilities.c