Arduino megaAVR Analog Comparator, e.g. Nano Every ATmega4809 @robertssmorgasbord
Arduino megaAVR Analog Comparator, e.g. Nano Every ATmega4809  @robertssmorgasbord
Uploaded December 2025 | Updated September 2026, 4 days ago
The megaAVR 0-series MCU analog comparator …
↓↓↓ Complete description, time index and links below ↓↓↓

Over two years ago we explored the watchdog and reset controller of the Arduino Nano Every, respectively, ATmega4809 MCU (link below). Meanwhile I’m in need of the ATmega’s analog comparator (link below), so let’s have a look at it.

We start with a deep dive into the datasheet and have a quick look at existing libraries. Then we write our own code and test it with potentiometer, LED, oscilloscope and function generator. Finally we use an interrupt to measure frequency and test that too.

00:00 Intro – exploring the megaAVR analog comparator
01:01 Overview – block diagram from the datasheet
03:04 Registers – configuration from the datasheet
08:40 Electrical – characteristics from the datasheet
11:14 Existing libraries – MegaCoreX and analogComp
12:53 Code 1 – output on pin and serial monitor
21:27 Breadboard 1 – potentiometer, resistor and LED
22:16 Test 1 – LED switches on as designed at 2.5V
23:59 Breadboard 2 – function generator and scope
23:43 Test 2 – output pin toggled at more than 20MHz
30:55 Code 2 – frequency measurement using interrupt
34:11 Test 3 – interrupt service routine up to 200kHz
38:32 Wrap-up – next is the current project again, bye

Tutorials youtube.com/playlist?list=PLwq-2MnM58FKn3920rc1V0qoTsQDheTIw
Arduino Nano Every: The Better Nano? – Tests and Shootout with Nano v3 youtu.be/CHDnw7W3SoQ
Arduino Nano Every – Power Supply Architecture and Brownouts youtu.be/Jhvwm21N8qk
Arduino Nano Every: Four Hardware Serial Ports – Without Additional Hardware youtu.be/yG_ialcawho
Arduino megaAVR Watchdog & Resets, e.g. Nano Every ATmega4809 youtu.be/X_OBmDWmSHw
Arduino megaAVR Watchdog & Resets, e.g. Nano Every ATmega4809 – Errata youtu.be/wuEQdN83LiU
Arduino megaAVR Brownout Detector, e.g. Nano Every ATmega4809 – First Look youtu.be/AUujyJMlaNQ
My code drive.google.com/file/d/1dM9RQehR8Uj0n13en79mmpG5N5WsyLT1/view?usp=sharing
Github - MCUdude / MegaCoreX github.com/MCUdude/MegaCoreX/tree/master/megaavr/libraries/Comparator
Github - leomil72 / analogComp github.com/leomil72/analogComp
Microchip Technology ATmega4808/4809 Data Sheet ww1.microchip.com/downloads/en/DeviceDoc/ATmega4808-4809-Data-Sheet-DS40002173A.pdf

#arduino #arduinonano #avr #analog #comparator #analogcomparator #tutorials #tutorial #how-to #robertssmorgasbord
Arduino megaAVR Analog Comparator, e.g. Nano Every ATmega4809Proxxon KT 150 Compound Table Maintenance (Cleaning & Lubricating)Full Fly-by-Wire Electric Outboard (24): New Isolated RS-485 Transceiver (2)Full Fly-by-Wire Electric Outboard (10): Water Intrusion Detection Circuit & CodeElectronic Steering Wheel / Rudder Jog IP68 (15): Body (6)Haswing Protruar 2.0 24V Trolling Motor – Battery Indicator ImprovementChannel Announcement: Sorry, no video today or next week – I’m doing tax formsRØDE LAV-HEADSET Unboxing and First ImpressionsJFETs – The Dirty Details (1/3): TheoryMelexis MLX90363 Triaxis® Magnetometer & Arduino MCU – The Details (4)Full Fly-by-Wire Electric Outboard (39): Servo Mechanism AlternativesFull Fly-by-Wire Electric Outboard (3): Throttle Circuit & Code Prototype
Roberts Smorgasbord |

Arduino megaAVR Analog Comparator, e.g. Nano Every ATmega4809

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER