Thanks paul,
I do also have the LCD i2c library included.
is that the library you suggested?
This is my current code. It is rough draft.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
//PINS
int X = A0;
int Y = A1;
byte HOLD = 4;
byte Press = 5;
//VARIABLES
int XVAL;
int YVAL;
int Xx;
int Yy;
int XvalLeft;
int XvalRight;
int YvalLeft;
int YvalRight;
int XvalLeftA;
int XvalRightA;
int YvalLeftA;
int YvalRightA;
int XLMAXVAL;
int XRMAXVAL;
int YLMAXVAL;
int YRMAXVAL;
int count;
void setup() {
pinMode(HOLD, INPUT);
pinMode(Press, INPUT);
count = 1;
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print(" 7EVEN6IX ");
lcd.setCursor(0, 1);
lcd.print(" BRUUUTHERRRR ");
delay(5000);
}
void loop() {
XVAL = analogRead(X);
YVAL = analogRead(Y);
Xx = map(XVAL, 0, 1023, 1, 16);
Yy = map(YVAL, 0, 1023, 1, 16);
XvalLeft = map(XVAL, 0, 512, 100, 0);
XvalRight = map(XVAL, 512, 1023, 0, 100);
YvalLeft = map(YVAL, 0, 512, 100, 0);
YvalRight = map(YVAL, 512, 1023, 0, 100);
if (digitalRead, HOLD == HIGH) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("X");
lcd.setCursor(0, 1);
lcd.print("Y");
BarGraph();
}
if (digitalRead, HOLD == LOW) {
lcd.clear();
ScrollMax();
}
}
void BarGraph() {
if (XvalLeftA > XvalLeft) {
XLMAXVAL = XvalLeftA;
}
if (XvalRightA > XvalRight) {
XRMAXVAL = XvalRightA;
}
if (YvalLeftA > YvalLeft) {
YLMAXVAL = YvalLeftA;
}
if (YvalRightA > YvalRight) {
YRMAXVAL = YvalRightA;
}
XVAL = analogRead(X);
YVAL = analogRead(Y);
Xx = map(XVAL, 0, 1023, 1, 16);
Yy = map(YVAL, 0, 1023, 1, 16);
XvalLeft = map(XVAL, 0, 512, 100, 0);
XvalRight = map(XVAL, 512, 1023, 0, 100);
YvalLeft = map(YVAL, 0, 512, 100, 0);
YvalRight = map(YVAL, 512, 1023, 0, 100);
XvalLeftA = XvalLeft;
XvalRightA = XvalRight;
YvalLeftA = YvalLeft;
YvalRightA = YvalRight;
lcd.setCursor(Xx, 0);
lcd.print("7");
lcd.setCursor(Yy, 1);
lcd.print("6");
}
void ScrollMax() {
if (digitalRead, Press == HIGH); {
delay(25);
lcd.clear();
count++;
if (count = 4); {
count = 1;
}
}
switch (count) {
case 1:
lcd.setCursor(0, 0);
lcd.print("Max Readings");
break;
case 2:
lcd.setCursor(0, 0);
lcd.print("Left Right");
lcd.setCursor(0, 1);
lcd.print(XLMAXVAL);
lcd.setCursor(9, 1);
lcd.print(XRMAXVAL);
break;
case 3:
lcd.setCursor(0, 0);
lcd.print("Accel Decel");
lcd.setCursor(0, 1);
lcd.print(YLMAXVAL);
lcd.setCursor(9, 1);
lcd.print(YRMAXVAL);
break;
}
}