@Override
    public void setValue(Pin pin, double value) {

        // validate range
        if(value <= getMinSupportedValue()){
            value =  getMinSupportedValue();
        }
        else if(value >= getMaxSupportedValue()){
            value = getMaxSupportedValue();
        }

        // the DAC only supports integer values between 0..4095
        int write_value = (int)value;
        try {
            // create data packet and seed targeted value
            byte packet[] = new byte[3];
            packet[0] = (byte) MCP4725_REG_WRITEDAC;
            packet[1] = (byte) (write_value >> 4); // Upper data bits (D11.D10.D9.D8.D7.D6.D5.D4)
            packet[2] = (byte) (write_value << 4); // Lower data bits (D3.D2.D1.D0.x.x.x.x)

            // write packet of data to the I2C bus
            device.write(packet, 0, 3);

            // update the pin cache and dispatch any events
            super.setValue(pin, value);
        }
        catch (IOException e) {
            throw new RuntimeException("Unable to write DAC output value.", e);
        }
    }
@ Override public void setValue ( Pin pin , double value ) { if ( value <= getMinSupportedValue ( ) ) { value = getMinSupportedValue ( ) ; } else if ( value >= getMaxSupportedValue ( ) ) { value = getMaxSupportedValue ( ) ; } int write_value = ( int ) value ; try { byte packet [ ] = new byte [ 3 ] ; packet [ 0 ] = ( byte ) MCP4725_REG_WRITEDAC ; packet [ 1 ] = ( byte ) ( write_value > > 4 ) ; packet [ 2 ] = ( byte ) ( write_value << 4 ) ; device . write ( packet , 0 , 3 ) ; super . setValue ( pin , value ) ; } catch ( IOException e ) { throw new RuntimeException ( "Unable to write DAC output value." , e ) ; } }
Set the analog output value to an output pin on the DAC immediately.

@param pin analog output pin
@param value raw value to send to the DAC. (Between: 0..4095)