So I did a bit of reading up and realized I could use timers to achieve my goal.
So here is a bit of the new code.
#include <SimpleTimer.h>
#include <LiquidCrystal.h>LiquidCrystal lcd(8,9,10,11,12,13);
SimpleTimer timer;
static char input[50];
char printdata[50];
void get_serial_data()
{static unsigned int pos = 0;
Serial.println("Get_serial_data");
while (Serial.available()>0)
{
char inByte = Serial.read();switch(inByte)
{
case '/n':
input[pos] = 0;
Serial.println("gotdata");
process_data(input);
pos=0;
break;
case '/r':
break;
default:
if (pos<50-1)
input[pos++] = inByte;
break;
}
}
}void process_data(char * processdata)
{
Serial.println("Processdata");
if(strcmp(processdata,"clear") == 0)
lcd.clear();
timer.setInterval(1000, print_data);}
void print_data()
{
strcpy(printdata,input);
unsigned int l = strlen(printdata);
unsigned int x,y;
lcd.setCursor(0,0);
if (l <=16)
{
delay(100);
lcd.print(printdata);
return;
}
for ( x=0; x<l-16;x++)
{
for(y=x;y<x+16;y++)
{
lcd.print(printdata[y]);
}
if ( x == 0) delay(800);
delay(200);
lcd.home();
}
delay(800);
}
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
timer.setInterval(1000, get_serial_data);
}void loop()
{
timer.run();}
But I think I have a few issues with the char array I am trying to print. I am getting one long array of all my serial input commands.
Would really appreciate inputs as to how to approach this!
Thanks!