-
• #2
You could try:
function SPIreadOneRegister(regAddress, spi){ var d = spi.send([0x0B,regAddress,0x00], D31); return d[2]; }
You're sending 3 bytes so you'll get 3 bytes back - but it's the last one (index 2) that'll contain the data you need.
-
• #3
It still doesn't work
-
• #4
Try changing:
function SPIwriteOneRegister(regAddress, regValue, spi){ spi.write([0x0A, regAddress, regValue]); }
to
function SPIwriteOneRegister(regAddress, regValue, spi){ spi.write([0x0A, regAddress, regValue], D31); }
... you weren't specifying a 'CS' pin, so the writes likely wouldn't have been working.
Also, if you change:
function SPIreadOneRegister(regAddress, spi){ var d = spi.send([0x0B,regAddress,0x00], D31); return d[2]; }
to
function SPIreadOneRegister(regAddress, spi){ var d = spi.send([0x0B,regAddress,0x00], D31); print(d); return d[2]; }
Then what sort of things are printed to the console?
-
• #5
It worked writing my cs pin in write(), thank you very much!!
I just started working on puck.js and I'm trying to get data from my ADXL362 connected to it, but my code always returns me zeros or 255, here it is:
If you have any solution please tell me.