#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/adc.h"
#define ADC_PIN ADC1_CHANNEL_6 // GPIO34 (ADC1 Channel 6)
#define MAX_ADC 4095 // 12-bit ADC max value
#define MAX_ANGLE 270 // Full range of potentiometer in degrees
void app_main() {
// Configure ADC1
adc1_config_width(ADC_WIDTH_BIT_12); // 12-bit resolution (0-4095)
adc1_config_channel_atten(ADC_PIN, ADC_ATTEN_DB_11); // Attenuation for 0-3.3V input
while (1) {
int adcValue = adc1_get_raw(ADC_PIN); // Read ADC value
// Map ADC value to angle (0° to 270°)
float angle = (adcValue / (float)MAX_ADC) * MAX_ANGLE;
// Print the ADC value and corresponding angle
printf("ADC Value: %d, Angle: %.2f°\n", adcValue, angle);
vTaskDelay(pdMS_TO_TICKS(500)); // Delay 500ms
}
}