15 lines
276 B
C++
15 lines
276 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%)
|
|
uint8_t percentage = (raw * 100) / 4095;
|
|
|
|
return percentage;
|
|
}
|