diff --git a/include/uart.h b/include/uart.h
index 450451f..35e2264 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -14,7 +14,7 @@ void uart_init(uint16_t baud);
uint8_t uart_read();
-void uart_read(uint8_t* buffer, size_t size);
+void uart_read_bytes(uint8_t* buffer, size_t size);
void uart_write(uint8_t frame);
diff --git a/platformio.ini b/platformio.ini
index c50d16e..0138a8c 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -14,6 +14,7 @@ board = nanoatmega328
framework = arduino
build_src_filter =
+<*>
+ +*.c
-<.git/>
-<.svn/>
-
@@ -22,4 +23,5 @@ build_src_filter =
-
-
-
- +
\ No newline at end of file
+ -
+ +
\ No newline at end of file
diff --git a/src/adc/adc.cpp b/src/adc/adc.cpp
new file mode 100644
index 0000000..2a5b0b3
--- /dev/null
+++ b/src/adc/adc.cpp
@@ -0,0 +1,50 @@
+//
+// Created by servostar on 09.12.23.
+//
+
+#include "adc.h"
+#include
+
+void adc_init() {
+ DDRC = 0x0;
+ SET_BIT(ADCSRA, ADEN); // enable ADC
+
+ // set prescaler / precision for conversion
+ SET_BIT(ADCSRA, ADPS0);
+ SET_BIT(ADCSRA, ADPS1);
+ SET_BIT(ADCSRA, ADPS2);
+
+ // set reference voltage
+ SET_BIT(ADMUX, REFS0);
+}
+
+uint16_t adc_read(uint8_t channel) {
+ ADMUX &= 0xF0;
+ ADMUX |= (channel & 0xF0);
+ // trigger adc conversion
+ ADCSRA |= (1 << ADSC);
+ // wait until converted
+ while((ADCSRA & (1 << ADIF)) == 0);
+ return ADCL + (ADCH << 8);
+}
+
+static uint16_t recent_adc = 0;
+
+void init() {
+ uart_init(9600);
+ adc_init();
+}
+
+void loop() {
+ uint16_t adc_val = adc_read(0);
+ char buf[10] = { 0 };
+ itoa(adc_val, buf, 10);
+
+ if (recent_adc != adc_val) {
+ recent_adc = adc_val;
+
+ uart_write_string("Channel 0: ");
+ uart_write_string(buf);
+ uart_write_string("\n");
+ }
+}
\ No newline at end of file
diff --git a/src/adc/adc.h b/src/adc/adc.h
new file mode 100644
index 0000000..19b5919
--- /dev/null
+++ b/src/adc/adc.h
@@ -0,0 +1,13 @@
+//
+// Created by servostar on 09.12.23.
+//
+
+#ifndef ARDUINO_ADC_H
+#define ARDUINO_ADC_H
+
+#include "prelude.h"
+
+void init();
+void loop();
+
+#endif //ARDUINO_ADC_H
diff --git a/src/main.cpp b/src/main.cpp
index d48db58..06cb142 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -8,7 +8,8 @@ extern void loop();
//#include "trafficlight/trafficlight.h"
//#include "summer/summer.h"
//#include "summer_controlled/summer.h"
-#include "uart/uart_read_write.h"
+//#include "uart/uart_read_write.h"
+#include "adc/adc.h"
int main() {
init();