convert Function

Top  Previous  Next

Converts an analog input to a digital value.

Syntax

Cell.ADC.convert(pin)

Arguments

pinThe pin number on Port A to convert, range 0 - 7.

Return Value

An integer value from 0 to max proportional to the voltage on the pin.

Remarks

The input voltage is measured relative to the selected voltage reference. The actual voltage on the pin can be computed as follows:

 

V = Vref * Cell.ADC.convert(pin) / Cell.ADC.max;

 

where Vref has been assigned the actual reference voltage.

 

Any pin used for analog input should be designated as such with the enable property. This will reduce the the load on the analog source and allow a more accurate conversion.

See Also

max Constant, reference Property, enable Property