#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// String *contact = (int *)malloc(0 * sizeof(int));
String functions[4] = {"Add Contect", "View Contects", "Delete Contect"};
// byte Add[8] = {
// B01110,
// B01110,
// B11111,
// B11111,
// B11111,
// B11111,
// B01110,
// B01110
// };
// byte view[8] = {
// B00000,
// B00000,
// B01010,
// B00000,
// B10001,
// B01110,
// B00000,
// B00000
// };
// byte del[8] = {
// B00100,
// B11111,
// B11111,
// B01110,
// B01110,
// B01110,
// B01110,
// B00000
// };
String label[5] = {"Contect Setting","Add Contect", "View Contects", "Delete Contect"};
String val[4] = {"HARIHARAN", "9876543109", "1", "A+"};
String contect[10] ;
//String *number = (char*)malloc(1 * sizeof(char));
uint8_t arrow[8] = {
0x00,
0x04,
0x06,
0x1F,
0x1F,
0x06,
0x04,
0x00
};
byte circule[8] = {
B00000,
B00000,
B00100,
B01110,
B11111,
B01110,
B00100,
B00000
};
int index = 0;
int vert, horz ;
int home(int custom_char, int cursor_col, int cursor_row, int label_row1, int label_row2)
{
lcd.clear();
lcd.setCursor(cursor_col, cursor_row);
lcd.write(byte(custom_char));
lcd.setCursor(1, 0);
lcd.print(label[label_row1]);
lcd.setCursor(1, 1);
lcd.print(label[label_row2]);
}
int setindex(int indx)
{
if (index == 0 )
{
home(1, 0, 0, index, index + 1);
}
if (index == 1)
{
home(0, 0, 1, index - 1, index);
}
if (index == 2)
{
home(0, 0, 0, index, index + 1);
}
if (index == 3)
{
home(0, 0, 1, index - 1, index);
}
}
void setup() {
lcd.createChar(0, arrow);
lcd.createChar(1, circule);
lcd.begin(16, 2);
Serial.begin(115200);
pinMode(7, INPUT_PULLUP);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
}
void loop() {
vert = analogRead(A0);
horz = analogRead(A1);
//Serial.println(vert);
if (index == 0 ) {
setindex(index);
do{
vert = analogRead(A0);
// horz = analogRead(A1);
}while(vert == 512);
}
if (vert == 1023 && index > 0)
{
index--;
setindex(index);
Serial.println(index);
}
if (vert == 0 && index < (sizeof(label)/sizeof(int)))
{
index++;
setindex(index);
Serial.println(index);
}
if (horz == 1023)
{
setindex(index);
}
if (horz == 0)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(val[index]);
}
if(digitalRead(7) == LOW)
{
if(index == 1)
{
Serial.println("Add Contect");
Serial.println("Enter a Name");
if (Serial.available() > 0) {
contect[0] = Serial.readString();
Serial.print("Recived String");
Serial.println(contect[0]);
}
}
if(index == 2)
{
lcd.clear();
lcd.print(contect[0]);
}
}
delay(100);
}