When reading analog signals the microcontroller converts the voltage to digital signals using analog to digital conversion (ADC).
The simplest conversation is that of a single input. The signal is converted to a digital signal and stored in a register on the microcontroller. This value is used by the deployed code to reconstruct the analog signal.
In some microcontrollers, it is also possible to use differential channels and amplify the signal before doing the conversion.
The signals and must be positive.
It is possible to use the voltages , , , or as the input signal.
Ain+, assuming Ain- is 0
Ain+, assuming Ain- is v
Ain-, assuming Ain+ is Ref
Ain-, assuming Ain+ is v
use gain "g"
use specifications spi
Analog input specifications.
Load the package.
Adjust the brightness of the LED on pin with the potentiometer connected to "A4":
Use the differential value between pins "A4" and "A5" to get the voltage at pin "A4":
It may be possible to specify additional options for the ADC conversion. They include "Reference" and "Prescaler".
The following values can be given for the ADC reference voltage:
Use the voltage of at the AREF pin as the reference voltage.
The ADC may need to happen at a different speed than the microcontroller's system clock speed. There is a prescaler that can be used to do the conversion at the appropriate speed. The prescaler value is automatically selected based on the system clock frequency and information in the datasheet. This value can also be explicitly specified.
Use a prescaler of to scale down the input clock for ADC.
The actual reference and prescaler values can be obtained from the "ADC" property.