I am trying to send a 16 bit command to a Half bridge (data sheet here http://www.onsemi.com/pub/Collateral/NCV7719-D.PDF) to open one of the transistors to turn on an LED. at the bottom of the data sheet (page 13) it says which bit needs to be a 1 or a 0 in order to activate the half bridge. This is the code I wrote but it isn't work (I'm assuming I'm not sending the 16 bits properly). Can someone figure out why this isn't working?

#include <SPI.h>

void setup() {
  // put your setup code here, to run once:


void loop() {
  // put your main code here, to run repeatedly:

  //pulling pin low to decide to write to device 

  //function to send information
  //truning on half bridge 4 
  //finish transfering data

  • FYI, 0000010000000000 is not a binary constant in C++ syntax. – Dmitry Grigoryev May 29 '18 at 11:18

SPI writes in 8-bit bytes. So the writes need to look like this:

  SPI.transfer(0b00000100);  // first byte
  SPI.transfer(0b00000000);  // second byte

Possibly in the other order depending on which byte the device expects first.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.