potentiometer add

This commit is contained in:
Rchurakov committed 2023-03-30 17:00:05 +03:00
1 parent 27e20c0bf1
commit 4e25cc047b
2 files changed
+28

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
#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;
}
+7
View File
@@ -0,0 +1,7 @@
#ifndef POTENTIOMETER_H
#define POTENTIOMETER_H
void pot_Initialization(void);
float get_pot_value(void);
#endif /*POTENTIOMETER_H*/