LTC1609 ADC example code

Hi,

I'm trying to read data from a ltc1609 ADC from linear technology into my computer using matlab. The problem is that i'm not very familiar with this IC so im using SPI library from Arduino to read data coming from ADC and then sending this data via Serial to Matlab. I found a code in this forum, but I changed it to my convenience to see if it was working fine, here is the code:

#include<SPI.h>
int  rcPin    =  7;
int  adcPin   =  9;
int  sdPin    =  10;
int  busy     =  2;
unsigned int a1 = 0;
unsigned int a2 = 0;
unsigned int a3 = 0;
unsigned int a[3];
int ledPin = 3;
unsigned long i=0;
byte  LowByte,HighByte;
unsigned int  adcValue =  0;



void setup(){
  pinMode(ledPin,OUTPUT);
  pinMode(adcPin,OUTPUT);
  pinMode(sdPin, OUTPUT);
  pinMode(rcPin, OUTPUT);
  pinMode(busy,INPUT);
  digitalWrite(adcPin,HIGH);
  digitalWrite(sdPin,HIGH);
  Serial.begin(9600);
  SPI.begin();
  //SPI.setBitOrder(MSBFIRST);
  //SPI.setClockDivider(SPI_CLOCK_DIV4);
  //SPI.setDataMode(SPI_MODE0);
  delay(100);
  digitalWrite(adcPin,LOW);
  digitalWrite(rcPin,HIGH);
  delay(100);
  Serial.println("start");
}

void loop(){
  digitalWrite(adcPin,LOW);
  //Serial.write(busy);
  //Serial.write(busy);
  a1 = digitalRead(busy);
  digitalWrite(rcPin,LOW);
  delay(1000);
  digitalWrite(rcPin,HIGH);
  
  //Serial.write(busy);
  //Serial.write(busy);
  a2 = digitalRead(busy);
  while(!digitalRead(busy)){
    LowByte = SPI.transfer(0x00);
  //Serial.println(LowByte,DEC);
  HighByte = SPI.transfer(0x00);
  //Serial.println(HighByte, DEC);
  adcValue = HighByte * 256 + LowByte;
  digitalWrite(adcPin,HIGH);
  //Serial.println(adcValue,DEC);
  //Serial.write(adcValue);
  a3 = adcValue;
  Serial.write(0);
  
  }
  a3 = 1;
  if (Serial.available()>0)
  {
       Serial.write(a1);
        Serial.write(a2); 
       Serial.write(a3); 
    
  }
  
   
    
   //Serial.write(1);
  
  
 
}

Idk if this code is right or wrong cuz i couldn't discover wht pin from the ADC was adcPin and sdPin (i think is chip select). Basically this code set the ADC and then I send anything from Matlab to get the bytes from busy and the value of the ADC. This code was made to see if the busy pin was working fine (and for me to understand the functionality) but i'm not sure if it's working fine.

Can someone help/guide me to understand this better?

I want to see if i can read 5V analog to digital with this ADC.

Thank you very much.

Regards

working code https://www.reddit.com/r/arduino/comments/3gtzcz/arduino_adc_programming_help/?

thanks for the reply!

Actually my code is based on that code but my problem is that idk wht does the adcPin (pin 9 on arduino) do with the ADC. That's my main problem. I've tested the code, but I'm not getting the right values.