#include "Wire.h"
#include "I2Cdev.h"
#include "ADXL345.h"
ADXL345 accel;
int16_t ax, ay, az;
#define LED_PIN 13
bool blinkState = false;
void setup() {
Wire.begin();
Serial.begin(38400);
Serial.println("Initializing I2C devices...");
accel.initialize();
Serial.println("Testing device connections...");
Serial.println(accel.testConnection() ? "ADXL345 connection successful" : "ADXL345 connection failed");
pinMode(LED_PIN, OUTPUT);
}
void loop() {
accel.getAcceleration(&ax, &ay, &az);
Serial.print("accel:\t");
Serial.print(ax); Serial.print("\t");
Serial.print(ay); Serial.print("\t");
Serial.println(az);
blinkState = !blinkState;
digitalWrite(LED_PIN, blinkState);
}
这不叫“翻译”。你的标题应该改为“请帮我给下面C程序添加注释,看不懂”。
#include "Wire.h"