3 axis arduino code
/*
* Project name:
3 AXIS ACCELEROMETER
* Copyright
(c) Researchdesignlab.com
* Description:
* Test configuration:
MCU: ATMEGA328
Dev.Board: Arduino uno
Oscillator: 16 MHz
Software: Arduino
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 2, 3, 4, 5); // initialize the library with the numbers of the interface pins
const int groundpin = 18; // analog input pin 4 -- ground
const int powerpin = 19; // analog input pin 5 -- voltage
const int xpin = A3; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
void setup()
{
lcd.begin(16,2);
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
void loop()
{
lcd.print(analogRead(xpin)); // print the sensor values:
lcd.print(" "); // print a tab between values:
lcd.print(analogRead(ypin));
lcd.print(" ");
lcd.print(analogRead(zpin));
lcd.println();
delay(100); // delay before next reading:
}