diff --git a/earthquake/earthquake.ino b/earthquake/earthquake.ino
index c9b115fc283c849f1b1f6755f1b85272e703bbe8..33ff706760c5363cdd686ed5215579ad44ddf525 100644
--- a/earthquake/earthquake.ino
+++ b/earthquake/earthquake.ino
@@ -1,10 +1,16 @@
-#include <LiquidCrystal.h>
+#include <LiquidCrystal_I2C.h>
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
+/*--------------------
+ * I2C LCD
+ --------------------*/
+
+LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
+
/*--------------------
* Pin const
*--------------------*/
@@ -83,10 +89,15 @@ void ledActive();
void ledDeactive();
void gyroOn();
void gyroOff();
+void printLCD(int,int,String);
+void clearLCD();
void setup() {
Serial.begin(115200);
+
+ lcd.begin(16,2);
+ lcd.backlight();
// Toggle button
toggleButtonInit();
@@ -103,7 +114,6 @@ void setup() {
}
void loop() {
- loopNumber++;
reading = digitalRead(inPin);
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
@@ -118,8 +128,12 @@ void loop() {
if(state == HIGH){
gyroOn();
+ clearLCD();
+ printLCD(0,0,"Arduino ON");
} else {
gyroOff();
+ clearLCD();
+ printLCD(0,0,"Arduino OFF");
}
}
@@ -292,3 +306,14 @@ void gyroOff(){
displaySevenSegment(0);
ledDeactive();
}
+
+
+void printLCD(int x,int y,String str){
+ lcd.setCursor(x,y);
+ lcd.print(str);
+}
+
+void clearLCD(){
+ lcd.clear();
+}
+