/* Program by R. Jordan Kreindler to show how a DAC works A 10mm Red LED is used here. One side is connected to a 220 ohm resistor. The other side is connected to one of the DAC pins: GPIO26 */ #define DAC2 26 // Identify the digital to analog convertor pin int delay1 = 10; // The delay between successive writes void setup() { } void loop() { // Fade up for (int i = 0; i < 256; i++) { // i = 255 = 3.3 volts, i = 0 = 0.0 volts dacWrite(DAC2, i); delay(delay1); } // Fade down for (int i = 255; i > -1; i--) { dacWrite(DAC2, i); delay(delay1); } }