I want to interface with an AD7314 Temperature Sensor. I want to only read the temperature value from the sensor and output the value on to 8 LEDs connected to the Arduino. But so far I have not been able to read from the sensor. The datasheet says that the temperature readings are in 10 bit 2's complement, so I plan to convert to 8 bit before putting it out on the LEDs. Here is my code so far.
I am new to SPI and clearly don't understand the temperature sensor's datasheet. Please can anyone elaborate or explain where I am going wrong?
Note: I have chosen pin A0 (PIN 23 of ATMEGA328P) as slave select and not pin 10
#include <SPI.h>
byte val;
void setup (void) {
pinMode(0, OUTPUT); //LED 1
pinMode(1, OUTPUT); //LED 2
pinMode(5, OUTPUT); //LED 3
pinMode(6, OUTPUT); //LED 4
pinMode(7, OUTPUT); //LED 5
pinMode(8, OUTPUT); //LED 6
pinMode(9, OUTPUT); //LED 7
pinMode(10, OUTPUT);//LED 8
pinMode(11, OUTPUT); // MOSI
pinMode(12, INPUT); //MISO
pinMode(13, OUTPUT); //CLOCK PIN
digitalWrite(A0, HIGH); // ensure Slave select stays high
SPI.begin ();
Serial.begin(9600);
} // end of setup
void loop (void) {
// enable Slave Select
digitalWrite(A0, LOW); // enable communication with slave
delay (0.425);// wait for conversion
val = SPI.transfer(0x00);// read from sensor
Serial.println(val); // display reading on serial monitor
// disable Slave
digitalWrite(A0, HIGH);
}