一、DAC
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/uart.h"
#include <driver/dac.h>
void app_main()
{
dac_output_enable(DAC_CHANNEL_1);
while(1){
dac_output_voltage(DAC_CHANNEL_1, 200);
}
}
二、ADC
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/uart.h"
#include <driver/adc.h>
void app_main()
{
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(ADC1_CHANNEL_0,ADC_ATTEN_DB_0);
while(1){
int val = adc1_get_raw(ADC1_CHANNEL_0);
printf("The voltage is: %d\n",val);
}
}