Module dac

Source
Available on crate feature unstable only.
Expand description

§Digital to Analog Converter (DAC)

§Overview

Espressif devices usually have multiple DAC channels. Each DAC channel can convert the digital value 0~255 to the analog voltage 0~Vref (The reference voltage ‘Vref’ here is input from an input pin)

The DAC peripheral supports outputting analog signal in the multiple ways.

Two 8-bit DAC channels are available.

§Configuration

Developers can choose the DAC channel they want to use based on the GPIO pin assignments for each channel.

§Examples

§Write a value to a DAC channel

let dac1_pin = peripherals.GPIO25;
let mut dac1 = Dac::new(peripherals.DAC1, dac1_pin);

let mut delay = Delay::new();

let mut voltage_dac1 = 200u8;

// Change voltage on the pins using write function:
loop {
    voltage_dac1 = voltage_dac1.wrapping_add(1);
    dac1.write(voltage_dac1);

    delay.delay_ms(50u32);
}

Structs§

Dac
Digital-to-Analog Converter (DAC) Channel