SPI communication: Reading data register using Arduino Leonardo

Hi,

I am currently working on a project and having a hard getting my Arduino Leonardo to read data from AMC 7812 register. Please help

Thank you!

Here is some code I am using:

#include <SPI.h>
const int slaveSelectPin = 10;

void setup() {
Serial.begin(115200);
// set the slaveSelectPin as an output:
pinMode (slaveSelectPin, OUTPUT);
// initialize SPI:
SPI.begin(); 
}

void loop() {
 int result;

 // Begin a read or write cycle
 digitalWrite(slaveSelectPin, LOW);  //Enable the slave

 // Send the command to read register 0
 SPI.transfer(0x00);

 // Now read a byte from the chip.  THE VALUE WE SEND MAKES NO DIFFERENCE WHEN READING.
 // We just need to generate 8 clock pulses and sample the MISO line to get the data.
 //  Sending a byte will generate the clock pulses

 result = SPI.transfer(0x33); 

 //  Register read operation complete
 digitalWrite(slaveSelectPin, HIGH);  

 Serial.print("Register 0 contains 0x");
 Serial.println(result, HEX);

 delay(1000);
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Yeah we know - you told us in your TWO other identical posts.

Can we get a moderator over here, PDQ?

Kafou:
I am currently working on a project and having a hard getting my Arduino Leonardo

This is not the Forum for that sort of thing :slight_smile:

...R

@Kafou, do not cross-post. Other threads removed.

I am sorry I am new here, I wasn't sure where to post the question.

Sorry for that.