#include <LiquidCrystal.h> //Include LCD library for using LCD
#include <Wire.h> //Include WIre library for using I2C
/* Display */
LiquidCrystal lcd(2,3,4,5,6,7); //Define LCD display pins RS,E,D4,D5,D6,D7
const int MPU_addr=0x68; //I2C MPU6050 Address
#include <Wire.h>
#include <MPU6050.h>
#define period 10000
MPU6050 mpu;
int count=0;
char okFlag=0;
byte degree[8] = {
0b00000,
0b00110,
0b01111,
0b00110,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup()
{
lcd.begin(16,2);
lcd.createChar(0, degree);
Serial.begin(9600);
Serial.println("Initialize MPU6050");
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
{
lcd.clear();
lcd.print("Device not Found");
Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
delay(500);
}
count=0;
mpu.calibrateGyro();
mpu.setThreshold(3);
lcd.clear();
lcd.print("MPU6050 Interface");
lcd.setCursor(0,1);
lcd.print(" Circuit Digest");
delay(2000);
lcd.clear();
}
void loop()
{
lcd.clear();
lcd.print("Temperature");
long st=millis();
Serial.println("Temperature");
while(millis()<st+period)
{
lcd.setCursor(0,1);
tempShow();
}
lcd.clear();
lcd.print("Gyro");
delay(2000);
st=millis();
Serial.println("Gyro");
while(millis()<st+period)
{
lcd.setCursor(0,1);
gyroShow();
}
lcd.clear();
lcd.print("Accelerometer");
delay(2000);
st=millis();
Serial.println("Accelerometer");
while(millis()<st+period)
{
lcd.setCursor(0,1);
accelShow();
}
}
void tempShow()
{
float temp = mpu.readTemperature();
Serial.print(" Temp = ");
Serial.print(temp);
Serial.println(" *C");
lcd.clear();
lcd.print("Temperature");
lcd.setCursor(0,1);
lcd.print(temp);
lcd.write((byte)0);
lcd.print("C");
delay(400);
}
void gyroShow()
{
//lcd.setCursor(0,0);
lcd.clear();
lcd.print(" X Y Z");
Vector rawGyro = mpu.readRawGyro();
Vector normGyro = mpu.readNormalizeGyro();
lcd.setCursor(0,1);
lcd.print(normGyro.XAxis,1);
lcd.setCursor(6,1);
lcd.print(normGyro.YAxis,1);
lcd.setCursor(12,1);
lcd.print(normGyro.ZAxis,1);
Serial.print(" Xnorm = ");
Serial.print(normGyro.XAxis);
Serial.print(" Ynorm = ");
Serial.print(normGyro.YAxis);
Serial.print(" Znorm = ");
Serial.println(normGyro.ZAxis);
delay(200);
}
void accelShow()
{
// lcd.setCursor(0,0);
lcd.clear();
lcd.print(" X Y Z");
Vector rawAccel = mpu.readRawAccel();
Vector normAccel = mpu.readNormalizeAccel();
lcd.setCursor(0,1);
lcd.print(normAccel.XAxis,1);
lcd.setCursor(6,1);
lcd.print(normAccel.YAxis,1);
lcd.setCursor(12,1);
lcd.print(normAccel.ZAxis,1);
Serial.print(" Xnorm = ");
Serial.print(normAccel.XAxis);
Serial.print(" Ynorm = ");
Serial.print(normAccel.YAxis);
Serial.print(" Znorm = ");
Serial.println(normAccel.ZAxis);
delay(200);
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
imu1:INT
imu1:AD0
imu1:XCL
imu1:XDA
imu1:SDA
imu1:SCL
imu1:GND
imu1:VCC
lcd1:VSS
lcd1:VDD
lcd1:V0
lcd1:RS
lcd1:RW
lcd1:E
lcd1:D0
lcd1:D1
lcd1:D2
lcd1:D3
lcd1:D4
lcd1:D5
lcd1:D6
lcd1:D7
lcd1:A
lcd1:K
pot1:GND
pot1:SIG
pot1:VCC