4 Light LED if Potentiometer Value Below ADC Value
This ADC Window Comparator example will demonstrate how to initialize the ADC, set the conversion window comparator low threshold, enable the conversion Window mode, enable the Free Running mode, start the conversion, and then wait until the conversion is done to turn on the LED if the ADC result is below the set threshold or turn off the LED it the result is above the threshold. A potentiometer was used as the analog source.
For more on this and other ADC examples, see TB3209: “Getting Started with ADC” (DS90003209).
Instead of generating code by hand, the MPLAB Code Configurator (MCC) is used. The MCC is a plug-in available for installation under the MPLAB X IDE menu Tools>Plugins, Available Plugins tab. See MPLAB X IDE Help for more on how to install plugins.
For information on the MCC, including the “MPLAB® Code Configurator 3.xx User’s Guide” (DS40001829), go to the MPLAB Code Configurator web page at:
www.microchip.com/mplab/mplab-code-configurator
For this example, the MCC UI was set up as shown in the following sections.