smart_alarm/control.cpp
2025-09-20 18:09:58 +02:00

13 lines
227 B
C++

#include <cstdint>
#include "hardware/adc.h"
uint8_t get_knob_percentage() {
adc_select_input(0); // Select ADC channel 0
uint16_t raw = adc_read();
// Convert to percentage (0 to 100%)
return (raw * 100) / 4095;
}