adc works
This commit is contained in:
parent
545af2648e
commit
467ebb3e9c
|
@ -5,7 +5,7 @@
|
|||
#include <util/delay.h>
|
||||
|
||||
void adc_init() {
|
||||
//DDRA=0x0; // does not exist but is default?
|
||||
DDRC=0x0; // does not exist but is default?
|
||||
ADCSRA = (1<<ADEN)|(1<<ADPS1)|(1<<ADPS2);
|
||||
ADMUX = (1<<REFS0);
|
||||
}
|
||||
|
|
|
@ -14,16 +14,17 @@
|
|||
int main (void)
|
||||
{
|
||||
uart_init();
|
||||
adc_init();
|
||||
sei();
|
||||
|
||||
char buf[10];
|
||||
int sensor[2];
|
||||
uint16_t sensor[2] = { 0, 1 };
|
||||
|
||||
while (1)
|
||||
{
|
||||
// lets say we read some value from a sensor
|
||||
sensor[0] = adc_read(0);
|
||||
sensor[1] = adc_read(1);
|
||||
sensor[0] = adc_read(0);
|
||||
sensor[1] = adc_read(1);
|
||||
// we want to print this, so we store the ascii repr in our buffer
|
||||
uart_printi("sensor 0: ", sensor[0]);
|
||||
uart_printi("sensor 1: ", sensor[1]);
|
||||
|
|
Loading…
Reference in New Issue