⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bma020.pde

📁 基于arduino的BMA020采集
💻 PDE
字号:
#include <Wire.h>#define ACCELEROMETER 0x38 #define X_OUT1	   0x02 #define X_OUT2	   0x03#define Y_OUT1	   0x04 #define Y_OUT2	   0x05#define Z_OUT1	   0x06 #define Z_OUT2	   0x07void setup() {    Wire.begin();    Serial.begin(9600);}void loop() { short  temp;   temp=accRead(X_OUT2);  temp<<=8;  temp|=accRead(X_OUT1);  temp=temp>>6;  Serial.print("X: ");   Serial.print(temp, DEC);  Serial.print ("   ");            temp=accRead(Y_OUT2);  temp<<=8;  temp|=accRead(Y_OUT1);  temp=temp>>6;   Serial.print("Y: ");    Serial.print(temp, DEC);   Serial.print ("   ");       temp=accRead(Z_OUT2);   temp<<=8;   temp|=accRead(Z_OUT1);   temp=temp>>6;    Serial.print("Z: ");     Serial.print(temp, DEC);     Serial.println();          delay(100);}byte accRead(byte address){    byte val = 0x00;    Wire.beginTransmission(ACCELEROMETER);    Wire.send(address);    Wire.endTransmission();    Wire.requestFrom(ACCELEROMETER, 1);    	  val = Wire.receive();        Wire.endTransmission();    return val;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -