oneitusatu
Junior Member level 3
i am using arduino uno and try to interfacing with adc16 bit max 1416 datasheet >> **broken link removed**
but i still cant get the right value for reading adc,instead of -1 appears at output for reading 5volt
here is my code
so according to pin configuration (attached image)
heres my configuration:
thanks,
oneitusatu
but i still cant get the right value for reading adc,instead of -1 appears at output for reading 5volt
here is my code
Code:
#include "SPI.h"
int ss=10;
int adcValue;
byte highByte;
byte lowByte;
void setup(){
pinMode(ss, OUTPUT);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
Serial.begin(9600);
}
void loop()
{
//series of commandbit
digitalWrite(ss,LOW);
SPI.transfer(32);//command for comm reg to select ch1 and write to clock register
SPI.transfer(165);//command for clock reg to set 2,4576Mhz
SPI.transfer(16);//command for comm reg to write setup register
SPI.transfer(69);//command for setup reg to self calibration,unipolar,unbuffered,
SPI.transfer(8);//command for comm reg to read
SPI.transfer(56);//command for the comm to read data register
digitalWrite(ss,HIGH);
int adcValue = 0;
//read 16bit of data ADC
highByte = 0;
lowByte = 0;
highByte = SPI.transfer(0x00);
lowByte = SPI.transfer(0x00);
adcValue = highByte << 8;
adcValue = adcValue | lowByte;
digitalWrite(ss,HIGH);
Serial.print("analog value =");
Serial.println(adcValue, DEC) );
Serial.print('\n');
delay(1000);
}
so according to pin configuration (attached image)
heres my configuration:
sclk to pin 13
cs to pin 10
ain+ to 5v
ain- to gnd
ref+ to 5v
ref- to gnd
dout to pin 11
din to pin 12
vdd to 5v
gnd to gnd
thanks,
oneitusatu
Last edited: