ADXL355用的是 ADXL355-PMDZ板,该传感器共有12个引脚。
引脚的关系如下:
1 芯片选择(SCL);2 MOSI(SDA为I2C通信的引脚);
3 MISO; 4 串行时钟(SCLK);
5 接地(GND); 6 数字电源(VCC);
Arduino UNO R3上的引脚:
1连7,2连11,3连12,4连13.
电源接3.3V,接地直接接地。
在这里插入代码片
#include <SPI.h>
// Memory register addresses:
const int XDATA3 = 0x08;
const int XDATA2 = 0x09;
const int XDATA1 = 0x0A;
const int YDATA3 = 0x0B;
const int YDATA2 = 0x0C;
const int YDATA1 = 0x0D;
const int ZDATA3 = 0x0E;
const int ZDATA2 = 0x0F;
const int ZDATA1 = 0x10;
const int RANGE = 0x2C;
const int POWER_CTL = 0x2D;
// Device values
const int RANGE_2G = 0x01;
const int RANGE_4G = 0x02;
const int RANGE_8G = 0x03;
const int MEASURE_MODE = 0x06; // Only accelerometer
// Operations
const int READ_BYTE = 0x01;
const int WRITE_B