Hello,
I am new to the Forum, Arduino and Electronics in general, although for whatever reason my only "cum laude" while studying my degree was in electronics... ![]()
Now i have a problem when i am interfacing arduino due board and adxl345 accelerometer. Being at the bottom of the learning curve, I opted for the Due and ADXL345 accelerometers, connected via SPI. I know now that it was not the best of the decissions, but once taken I have to make it work, even if it is only one accelerometer. As a backup plan I have ordered 4 analog ADXL335 that should make the trick.
Unfortunately, I am having issues with the SPI connection to the DUE. I can access the accelerometer data via I2C, but when trying to get to it through SPI i get nothing, only -1,-1,-1 but i got the device ID(for adxl345 is 0xE5 means in decimal is 229). I started trying to adapt the existing sketch from sparkfun for the due ADXL345 Hookup Guide - SparkFun Learn, but as it did not work I tried my low level implementation.
When i upload this code attached at below in arduino due board, it gives values of x, y, z are -1, -1, -1 respectively. When i changed the position of adxl345, values can not be changed. It gives constant values are -1, -1, -1. So how i can changed these values when i chenged the position of adxl345.
Please give response/answer as soon as possible. Give a perfect code for spi mode and interfacing image of arduino due and adxl345 and showing results which you can get.
spi.txt (4.06 KB)