0% found this document useful (0 votes)
3 views

MV project code

Uploaded by

Riasat Shah
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

MV project code

Uploaded by

Riasat Shah
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <LiquidCrystal.

h>

const int RS = 12;


const int EN = 11;
const int D5 = 5;
const int D4 = 4;
const int D3 = 3;
const int D2 = 2;
int Xread;
int Xrest;

int Yread;
int Yrest;

int Zread;
int Zrest;

double Gx;
double Gy;
double Gz;

int xpin = A0;


int ypin = A1;
int zpin = A2;

int t1;

LiquidCrystal lcd(RS, EN, D5, D4, D3, D2);

void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
digitalWrite (13, HIGH);
delay(1000);
Xrest = analogRead(xpin);
Serial.print(Xrest);

Yrest = analogRead(ypin);
Serial.print(Yrest);

Zrest = analogRead(zpin);
Serial.print(Zrest);

digitalWrite(13, LOW);
}

void loop() {
Serial.print("Time ");
t1=millis();
Serial.println(t1*0.001);

Xread = analogRead(xpin)-Xrest;
Yread=analogRead(ypin)-Yrest;
Zread=analogRead(zpin)-Zrest;

Gx=Xread/67.584;
Gy=Yread/67.584;
Gz=Zread/67.584;
Serial.print("Acceleration X :");
Serial.print(Gx);
Serial.print("Acceleration Y :");
Serial.print(Gy);
Serial.print("Acceleration Z :");
Serial.print(Gz);
Serial.print("\n");

lcd.setCursor(0, 0);
lcd.print("gx:");
lcd.print(Gx);
lcd.setCursor(8, 0);
lcd.print("gy:");
lcd.print(Gy);
lcd.setCursor(0, 1);
lcd.print("gz:");
lcd.print(Gz);
delay(100);
lcd.clear();
}

You might also like