StarProjector/analog_read.c
Brett Weiland e811d778ea init
2023-10-27 07:10:26 -05:00

20 lines
360 B
C

#include <avr/io.h>
#include "pins.h"
void init_adc() {
PRR = 0;
DDRF = 0;
//enable ADC0 input, refrence is AREF (wire to 5v)
ADMUX = 0b01100000;
//enable adc, disable interrupts, clear pending reading, slowest speed
ADCSRA = 0b10000111;
}
uint8_t analog_read_8bit() {
ADCSRA |= (1 << ADSC);
while(ADCSRA & (1 << ADSC));
return ADCH;
}