Control LED Brightness using DAC with an ESP32

Description: A TinyPico V2 (ESP32) controls an LED’s brightness using a DAC (Digital Analog Converter) Pin.

Control LED Brightness using DAC with an ESP32

Notes: There are only two DAC pins on the TinyPICO V2, pin 25 and pin 26.

Supplies:

1 – Breadboard 400 Points
1 – TinyPICO V2
1 – LED
1 – 220 Ohm Resistor

Arduino Code:

#include <driver/dac.h>

void setup() {

 dac_output_enable(DAC_CHANNEL_1);

}

void loop() {

  dac_output_voltage(DAC_CHANNEL_1, 0);
  delay(500);
  dac_output_voltage(DAC_CHANNEL_1, 140);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 170);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 200);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 230);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 255);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 230);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 200);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 170);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 140);
  delay(700);
  dac_output_voltage(DAC_CHANNEL_1, 0);
  delay(500);
  
}

Leave a Comment

− 1 = 1