Merge branch 'bugfix/example_adc_pin' into 'master'
Changed adc GPIO pin 32, that is not jumped to header in ESP-WROVER-KIT, to 34 See merge request !1020
This commit is contained in:
commit
f6193a68a5
|
@ -1,17 +1,14 @@
|
||||||
# Example: ADC1
|
# Example: ADC1
|
||||||
|
|
||||||
This test code shows how to configure ADC1 and how to use ADC1 get the voltage.
|
This test code shows how to configure ADC1 and read the voltage connected to GPIO pin.
|
||||||
|
|
||||||
|
|
||||||
####ADC1 functions:
|
### ADC1 functions:
|
||||||
|
|
||||||
* ADC1,CHANNEL_4:GPIO32, voltage range [0v,3.1v],the Data range [0,4095]
|
ADC1_CHANNEL_6: GPIO34, voltage range [0V..3.1V], the data range [0..4095]
|
||||||
|
|
||||||
|
|
||||||
####Test:
|
### Test:
|
||||||
* Please connect the test voltage to GPIO32
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Please connect the test voltage to GPIO34
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "driver/adc.h"
|
#include "driver/adc.h"
|
||||||
|
|
||||||
#define ADC1_TEST_CHANNEL (4)
|
#define ADC1_TEST_CHANNEL (ADC1_CHANNEL_6)
|
||||||
|
|
||||||
void adc1task(void* arg)
|
void adc1task(void* arg)
|
||||||
{
|
{
|
||||||
// initialize ADC
|
// initialize ADC
|
||||||
adc1_config_width(ADC_WIDTH_12Bit);
|
adc1_config_width(ADC_WIDTH_12Bit);
|
||||||
adc1_config_channel_atten(ADC1_TEST_CHANNEL,ADC_ATTEN_11db);
|
adc1_config_channel_atten(ADC1_TEST_CHANNEL, ADC_ATTEN_11db);
|
||||||
while(1){
|
while(1){
|
||||||
printf("The adc1 value:%d\n",adc1_get_voltage(ADC1_TEST_CHANNEL));
|
printf("The adc1 value:%d\n",adc1_get_voltage(ADC1_TEST_CHANNEL));
|
||||||
vTaskDelay(1000/portTICK_PERIOD_MS);
|
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||||
|
|
Loading…
Reference in a new issue