https://github.com/mkwapisz2000/c-atmega328p-adc-interrupts
This project demonstrates the handling of the Analog-to-Digital Converter (ADC) in the ATmega328P microcontroller using external interrupts.
https://github.com/mkwapisz2000/c-atmega328p-adc-interrupts
adc atmega328p avr c electronics embedded interrupts microcontroller
Last synced: about 2 months ago
JSON representation
This project demonstrates the handling of the Analog-to-Digital Converter (ADC) in the ATmega328P microcontroller using external interrupts.
- Host: GitHub
- URL: https://github.com/mkwapisz2000/c-atmega328p-adc-interrupts
- Owner: MKwapisz2000
- Created: 2025-02-13T10:46:32.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-02-13T10:58:04.000Z (3 months ago)
- Last Synced: 2025-02-13T11:35:10.670Z (3 months ago)
- Topics: adc, atmega328p, avr, c, electronics, embedded, interrupts, microcontroller
- Language: C++
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# c-atmega328p-adc-interrupts
**Project Description - English**
This project demonstrates how to handle the Analog-to-Digital Converter (ADC) in an ATmega328P microcontroller using external interrupts. The implementation in C directly accesses registers, without using Arduino libraries. The ADC conversion is triggered by an external interrupt (e.g., pressing a button).
Features:
- Configuration of external interrupts
- Manual ADC initialization
- Reading voltage values from A0 channel upon interrupt trigger
- Using ATmega328P microcontroller in pure C
Hardware Requirements:
- ATmega328P (e.g., Arduino Nano or standalone AVR)
- Button (switch) for generating interrupts
- Analog sensor or potentiometer
- LED (connected to a selected microcontroller pin)- Connecting wires
Usage Instructions:
- Compile the code using an AVR C-compatible environment (e.g., Atmel Studio, PlatformIO, AVR-GCC).
- Upload the program to the microcontroller using an ISP programmer.
- Press the button connected to INT0 to trigger the interrupt and read the ADC value.
- The LED will turn on or off depending on the measured voltage.----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
**Opis projektu - Polski**
Ten projekt demonstruje sposób obsługi przetwornika analogowo-cyfrowego (ADC) w mikrokontrolerze ATmega328P, przy wykorzystaniu przerwań zewnętrznych. Implementacja w języku C korzysta z bezpośredniego dostępu do rejestrów, bez użycia bibliotek Arduino. ADC jest uruchamiane w momencie wystąpienia przerwania zewnętrznego (np. naciśnięcia przycisku).
Funkcjonalność:
- Konfiguracja przerwań zewnętrznych
- Inicjalizacja ADC w trybie manualnym
- Odczyt wartości napięcia na kanale A0 po wystąpieniu przerwania
- Obsługa mikrokontrolera ATmega328P w czystym C
Wymagania sprzętowe:
- ATmega328P (np. Arduino Nano lub standalone AVR)
- Przycisk (switch) do generowania przerwań
- Czujnik analogowy lub potencjometr
- Dioda LED (podłączona do wybranego pinu mikrokontrolera)- Przewody połączeniowe
Instrukcja użytkowania:
- Skompiluj kod w środowisku obsługującym AVR C (np. Atmel Studio, PlatformIO, AVR-GCC).
- Wgraj program do mikrokontrolera przy użyciu programatora ISP.
- Naciśnij przycisk podłączony do pinu INT0, aby wyzwolić przerwanie i odczytać wartość ADC.
- Dioda LED zapali się lub zgaśnie w zależności od odczytanego napięcia.