Monitor a break system
Posted: Sun Jun 16, 2024 1:20 am
I have a "thumb accelerator" similar to the ones found on most scooters. I want to read its value every time a user presses it.
What is the correct way to read an analog signal?
I have:
But I get warnings that these functions are deprecated. And then this, that I saw from the documentation:
What is the correct way to read the analog input from the device, and how should I structure my code, so it is efficient, given that I want to react as fast as possible?
What is the correct way to read an analog signal?
I have:
Code: Select all
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_DEFAULT, 0, &adc1_chars);
adc1_config_width(ADC_WIDTH_BIT_DEFAULT);
adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_DB_11);
Code: Select all
uint32_t reading = adc1_get_raw(ADC1_CHANNEL_5);
esp_adc_cal_characteristics_t *adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
uint32_t voltage = esp_adc_cal_raw_to_voltage(reading, adc_chars);