0

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);
}

Wiring diagram: enter image description here

Here is a snippet of the data sheet for the vu8:

enter image description here

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!

  • 2
    you must wire ground even if the sensor has separate power supply – Juraj Apr 23 at 19:45
  • Ya, ground is used as the reference for Signals as well as Power, so any two devices that are communicating need to have a shared ground. – Chad G Apr 23 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.