I'm very new to Arduino and have never used the SPI protocol before. I've tried following tutorials online, but my SPI.transfer always returns a value of 255 whether the sensor is connected or not. The sensor is a Leddar Vu8 and has external power. I have included my wiring diagram, as well as the code i have written so far. Any help on how to get the read register over SPI would be greatly appreciated. Thanks in advance!
#include <SPI.h>
const int slaveSelectPin = 10;
void setup() {
// set the slaveSelectPin as an output:
Serial.begin(9600);
pinMode(slaveSelectPin, OUTPUT);
// initialize SPI:
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV4);
SPI.begin();
delay(100);
}
void loop() {
digitalWrite(slaveSelectPin, LOW);
delay(500);
SPI.transfer(0x0B);
int data = SPI.transfer(0x00400000);
int data2 = SPI.transfer(0x0B);
delay(500);
Serial.println(data);
Serial.println(data2);
digitalWrite(slaveSelectPin, HIGH);
}
Here is a snippet of the data sheet for the vu8:
The rest of the data sheet can be found here: https://www.robotshop.com/media/files/pdf2/leddarvu_and_configurator_user_guide.pdf Starting on page 37.
Thanks in advance for any help!