PreviousNext
Help > RITTLE FOR THE PIC32MZ MICROCONTROLLER > Work with I/O ports > Ain
Ain

Format:                                                                        

real= Ain (integer_portN);

Read analogue input port and return a real number value between 0 and 1, proportional to the voltage on the port in respect to the set Vref+/Vref- values.

Example:

Let’s assume Rittle uses the default ADC referencing model, where Vref+ is taken from the positive power supply 3.3V, and Vref- is taken from the ground power rail 0V, and there is 1.88V (in respect to GND) applied on the AIN port 22.

Executing Ain(22) will return value 0.569697, which is proportional to the voltage over the entire range: 1.88/3.3 = 0.569697.