#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
int x=2; //button is connected to digital pin 2
int val=0,TC_num=0;
void setup()
{
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("TC Type= ");
lcd.setCursor(9,0);
lcd.print("NA"); // ("B Type")
}
void loop()
{
//read the value of the button when pressed
val=digitalRead(x);
if(val==1){ // button is pressed
TC_num=TC_num+1; // add 1 to the TC_num variable
}
if (TC_num==1){
lcd.setCursor(9,0);
lcd.print("B "); // ("B Type")
delay(10);
}
else if (TC_num==2){
lcd.setCursor(9,0);
lcd.print("E "); // ("E Type");
delay(10);
}
else if (TC_num==3){
lcd.setCursor(9,0);
lcd.print("J "); // ("J Type")
delay(10);
}
else if (TC_num==4){
lcd.setCursor(9,0);
lcd.print("K "); // ("K Type")
delay(10);
}
else if (TC_num==5){
lcd.setCursor(9,0);
lcd.print("N "); // ("N Type")
delay(10);
}
else if (TC_num==6){
lcd.setCursor(9,0);
lcd.print("R "); // ("R Type")
delay(10);
}
else if (TC_num==7){
lcd.setCursor(9,0);
lcd.print("S "); // ("S Type")
delay(10);
}
else if (TC_num==8){
lcd.setCursor(9,0);
lcd.print("T "); // ("T Type");
delay(10);
//*******************************************************************
//reset the TC_num variable to 0
TC_num=0;
//*********************************************************************
}
//wait 300 ms for the next reading
delay(300);
}