2ch 10-Bit DAC LTC1662

So I was working on a project and created this code for a DAC for the Arduino. No more using Capacitors and PWM.

//Code for LTC1662 2 channel DAC Converter
//By Weston Smith
//11-10-09

#define DATA_PIN 11
#define LOAD_PIN 13 //Set these 3 pins to your liking
#define CLOCK_PIN 12

void setup()
{
pinMode(DATA_PIN, OUTPUT); // sets the digital pins as outputs
pinMode(LOAD_PIN, OUTPUT);
digitalWrite(LOAD_PIN, HIGH);
pinMode(CLOCK_PIN, OUTPUT);
digitalWrite(CLOCK_PIN, LOW);
}

void updateDAC(int XYZ, int val) //val should be 0-1023
{
byte data1 = 0;
byte data2 = 0;

byte first =0;
byte mid = 0;

if(val>255)
mid = B00000100;
if(val>511)
mid = B00001000;
if(val>767)
mid = B00001100;

if(XYZ == ‘X’ || XYZ == ‘x’) //Updates Analog Output A
first = B10010000; //data1= ‘10010000’ First 4 bits are “Command Code”

if(XYZ == ‘Y’ || XYZ == ‘y’) //Updates Analog Output B
first = B10100000; // sets first four bits to 1010

if(XYZ == ‘Z’ || XYZ == ‘z’) //Updates Analog Output A & B to same value
first = B11110000; // sets first four bits to 1111

data1 = first + mid + (byte(val)>>6);
data2 = byte(val) << 2;

digitalWrite(LOAD_PIN, LOW);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, data1);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, data2);
digitalWrite(LOAD_PIN, HIGH);
}

void loop()
{

updateDAC(‘x’,1023);

}