#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
int i = 0;
char msg[20] = "Syntex 50% Sump 20% ";
int x = 0;
int op = 7;
int sp = 16;
int testingV = 7;
void setup()
{
//Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
Serial.begin(9600);
lcd.backlight();
lcd.print("Hey I am Arduino ");
i = sizeof(msg);
//i = strlen(msg);
/*
Serial.println(strlen(msg));
Serial.println(sizeof(msg));
for(int y = 0;y < i;y++){
Serial.print(y);
Serial.print(" ");
Serial.println(msg[y]);
}
Serial.println(" ");
Serial.print(i-2);
Serial.print(" ");
Serial.print(msg[i-2]);
Serial.print(" ");
Serial.print(i-1);
Serial.print(" ");
Serial.print(msg[i-1]);
Serial.print(" ");
Serial.print(i);
Serial.print(" ");
Serial.print(msg[i]);
Serial.println(" ");
*/
}
void loop()
{
lcd.setCursor(0,1);
float opf = getPercentage(op, 20);
char ops[5];
dtostrf(opf, 4, 2, ops);
//Serial.println(ops);
//OHT % age update
msg[op] = ops[0];
char opx = ' ';
if(opf > 9.0){
opx = ops[1];
}
if(op >=19){
msg[0] = opx;
}
else{
msg[op+1] = opx;
}
float spf = getPercentage(sp, 20);
char sps[5];
dtostrf(spf, 4, 2, sps);
//Sump % age update
msg[sp] = sps[0];
char spx = ' ';
if(spf > 9.0){
spx = sps[1];
}
if(sp >=19){
msg[0] = spx;
}
else{
msg[sp+1] = spx;
}
lcd.print(msg);
char pmsg = msg[0];
for(x = 0;x < i;x++)
{
msg[x] = msg[x+1];
}
msg[i-1] = pmsg;
if(sp <= 0){
sp = 19;
}
else{
sp = sp-1;
}
if(op <= 0){
op = 19;
}
else{
op = op -1;
}
//Serial.println(getPercentage(12.0, 50.0));
//Serial.println(msg);
//Serial.println((msg<<8));
delay(300);
/*
lcd.setCursor(i,0);
lcd.print("I am Arduino ");
lcd.setCursor(i,1);
lcd.print("How are you man ");
//Serial.println("How are you man");
i--;
if(i < -1){
i=16;
lcd.clear();
}
delay(200);
*/
}
float getPercentage(float senceValue, float refValue){
return (float)(((float)senceValue/(float)refValue)*100.0);
}