#include <AcceleroMMA7361.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
AcceleroMMA7361 accelero;
int
x;
int
y;
int
z;
void
setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
accelero.begin(13, 12, 11, 10, A0, A1, A2);
accelero.setARefVoltage(3.3);
accelero.setSensitivity(LOW);
accelero.calibrate();
lcd.setCursor(0,0);
lcd.print(
"X: "
);
lcd.setCursor(8,0);
lcd.print(
"Y: "
);
lcd.setCursor(0,1);
lcd.print(
"Z: "
);
}
void
loop()
{
x = accelero.getXRaw();
lcd.setCursor(3,0);
lcd.print(x);
y = accelero.getYRaw();
lcd.setCursor(11,0);
lcd.print(y);
z = accelero.getZRaw();
lcd.setCursor(3,1);
lcd.print(z);
Serial.print(
"nx: "
);
Serial.print(x);
Serial.print(
"ty: "
);
Serial.print(y);
Serial.print(
"tz: "
);
Serial.print(z);
delay(500);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น