when i first started i used this code and it printed to the lcd display fine
#include <LiquidCrystal.h>
LiquidCrystal lcd(4,5,6,7,8,9);
int data = 0;
int cardone[16] = {
2,53,57,48,48,50,57,51,49,67,51,56,50,13,10,3};
int cardthree[16] = {
2,53,57,48,48,50,57,52,55,50,69,49,57,13,10,3};
int cardfour[16] = {
2,53,57,48,48,50,57,50,67,57,69,67,50,13,10,3};
int cardfive[16] = {
2,53,57,48,48,50,57,55,66,48,49,48,65,13,10,3};
int newcard [16] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
float pay = 0;
float total = 0;
int i = 1;
int items = 0;
void setup ()
{
Serial.begin(9600);
Serial.flush();
lcd.begin (20,4);
lcd.clear();
lcd.setCursor(2,i);
delay(1000);
lcd.print ("Hello shopper");
delay(5000);
lcd.clear();
totalpay();
}
void totalpay()
{total=pay+total;
delay (500);
lcd.home();
lcd.print ("items:");
lcd.print (items);
lcd.print (" total:");
lcd.print (total,2);
delay (1000);
pay = 0;
}
void loop()
{
if (Serial.available() > 0)
{
delay(100);
for (int z=0; z<16; z++)
{
data=Serial.read();
newcard[z] = data;
Serial.flush();}
lcd.setCursor(0,i);
{
if (newcard[9] == cardone[9]){
lcd.print ("Heinz Baked Beans");
pay=0.10;
i++;
items++;
}
else if (newcard[9] == cardthree[9]) {
lcd.print ("pint skimmed milk");
pay=0.50;
delay (100);
i++;
items++;
}
else if (newcard[9] == cardfour[9]) {
lcd.print ("loaf white bread");
pay =0.70;
delay(100);
i++;
items++;
}
else if (newcard[9] == cardfive[9]) {
lcd.print ("6 eggs");
pay=0.25;
delay (100);
i++;
items++;
}
else{
lcd.print ("No match");
i++;
}
{totalpay();}
}
}
}
the problem with it was that it wrote over line 3 of the lcd display.
i needed to write new code to move all the lines up one and display the next line. i thought it best to store the lines in memory so i can then advance once again and introduce buttons to scroll up and down through the list.
at the moment i am just writting notes next to my new code so when i put it on here it will be easier to read.