Arduino has ADC ( Analog digital converter) and PWM (Pulse with modulation) but if you need true Analog out, you are out of luck. But all is not lost. We can add the analog capability to Arduino with MCP4725 12-Bit Digital to Analog converter. This nifty chip has also on board EEPROM so you can save your last value in case of power failure.  This chip has also 3.4Mbps Fast Mode I2C (Unfortunately Arduino does not support that speed), with Arduino you can update the output at around 200KHz. So lets jump in…

  1. Connect GY4725 with Arduino. Connection scheme is following:
    Arduino GY4725
    5V Vcc
    A4 SDA
    A5 SCL
  2. Open Arduino IDE -> Sketch -> Include Library -> Manage Libraries…
  3. Search “Adafruit MCP4725” and Install.
  4. Lets write the sketch:
    #include <Wire.h>
    //MCP4725 library
    #include <Adafruit_MCP4725.h>
    Adafruit_MCP4725 dac;
    void setup() {
      //Start Serial
      //Start DAC. DAC address 0x60 or 0x61
    void loop(){
      for(int x=1; x<4096; x++){
        dac.setVoltage(x,false); // Set DAC voltage. false = don't save to EEPROM
      for(int x=4095; x>1; x--){
        dac.setVoltage(x, false);

    Output waveform of the script:

  5. Version 2 of the sketch (loop part):
    void loop(){
      int randomVoltage = random(0,4096);


  6. And that’s all folks.

Download MCP4725 Datasheet.