4_Ust-vo_poluchenia_velichi.../potentiometer.c
2023-03-30 17:00:05 +03:00

22 lines
362 B
C

#include "potentiometer.h"
#include <avr/io.h>
int pot_value;
void pot_Initialization() {
ADMUX |= 0B00000101;
ADMUX |= 0B01000000;
ADCSRA |= 0B11000000;
ADCSRA |= (1 << ADIE);
sei();
ADCSRA |= 0B01000000;
}
ISR (ADC_vect) {
pot_value = ADCL | (ADCH << 8);
ADCSRA |= 0B01000000;
}
float get_pot_value() {
return pot_value * 0.00498046875;
}