Comparator Example Project

Last modified by Microchip on 2023/11/09 09:02

Analog Comparator and Voltage Reference Example

This hands-on project demonstrates a simple example of an analog comparator and reference voltage:
Bandgap reference as positive input (1.1V) and AIN1 as negative input. By wiring AIN1 (PD7) to Switch (SW0, PB7), which turns on to high (5 V) and off to GND, and wiring ACO (PE0) to PB5 (LED0), the output of the comparator (ACO, PE0) can be observed by checking the LED’s status.

  • Wiring: PD7 (AIN1) | PB7 (SW0; PE0 (ACO) | PB5 (LED0)

Xplained Board:

Xplained Board

Select File > New > Atmel Start Project.

Atmel Start Project​​

 

Create new project.

Atmel Create Project​​

 

Select ATmega328PB Xplained Mini.

Atmel Create Project Menu to Add Components​​

 

Add Software Components and select AC.

Atmel Software Components​​

 

Setup AC.

Atmel Setup AC​​

 

Pin Configurator view.

Atmel Pin Configurator View​​

 

Setup Clock Configurator.

Atmel Setup Clock Configurator​​

 

Generate Project.

Atmel Generate Project​​

 

View Project.

Atmel View Project​​

 

In Main.c, add keyboard scan and LED driver.

Atmel Keyboard Scan and LED Driver​​

 

Build and run.

Atmel Build and Run​​

 

Visit the download page to download the ATMega328PB Analog Comparator Demo.