#include <LiquidCrystal.h>
int count1=0;
int count2=0;
LiquidCrystal lcd(18, 5, 17, 16, 4, 0);
void setup() {
// set up the LCD's number of columns and rows:
Serial.begin(115200);
lcd.begin(16, 2);
}
void loop()
{
}
void serialEvent()
{
while(Serial.available())
{
char ch = Serial.read();
Serial.print(ch);
counts(ch);
}
}
void counts(char ch)
{
if(ch=='A')
{
count1+=1;
}
if(ch=='B')
{
count1-=1;
}
if(ch=='C')
{
count2+=1;
}
if(ch=='D')
{
count2-=1;
}
if(ch=='E')
{
count2=0;
count1=0;
}
lcd.clear();
lcd.setCursor(5, 0);
lcd.print("Count1 : "+String(count1));
lcd.setCursor(5, 1);
lcd.print("Count2 : "+String(count2));
delay(1000);
}