lcd_data_string("Serial Tx");
Delay(40);
lcdcmd(0x01); //clear screen
Delay(10);
len = strlen(msg);
for(i=0;i<len;i++)
{
lcddata(msg[i]);
Delay(10);
}
lcdcmd(0x0C0); //Move to Second Line of the LCD
COL = 0x0FF; //Make Port-2 as Input Port
while(1) //Infinite Loop
{
do
{
ROW = 0x00; //Groud all Row's
colLoc = COL; //Read all the Columns
colLoc = colLoc & 0x0F; //Mask the Unused Bits.
}while(colLoc != 0x0F); //Check until all the Keys are released
do
{
do
{
Delay(2); //20msec delay
colLoc = COL; //Read all the Columns
colLoc = colLoc & 0x0F; //Mask the Unused Bits.
}while(colLoc == 0x0F); //Keep Checking for Key-press
//It may be possible that this key-press may be due to some noise-spikes in the circuit
//thats why we will check once again whether the same key is pressed or not.
//If not the whole loop will be executed once again
Delay(2);
colLoc = COL; //read all columns
colLoc = colLoc & 0x0F; //Mask the Unused Bits.
}while(colLoc == 0x0F); //Wait for the Key-Press
while(1)
{
ROW = 0x0FE; //Ground First Row
colLoc = COL;
colLoc = colLoc & 0x0F; //Mask the Unused Bits.
if(colLoc != 0x0F) //1111 Column Detected
{
rowLoc = 0; //1st Row Selected
break;
}
ROW = 0x0FD; //Ground Second Row
colLoc = COL;
colLoc = colLoc & 0x0F; //Mask the Unused Bits.
if(colLoc != 0x0F) //Column Detected
{
rowLoc = 1; //2nd Row Selected
break;
}
ROW = 0x0FB; //Ground Third Row
colLoc = COL;
colLoc = colLoc & 0x0F; //Mask the Unused Bits.
if(colLoc != 0x0F) //Column Detected
{
rowLoc = 2; //3rd Row Selected
break;
}
ROW = 0x0F7; //Ground Fourth Row
colLoc = COL;
colLoc = colLoc & 0x0F; //Mask the Unused Bits.
if(colLoc!= 0x0F)
{
rowLoc = 3; //4th Row Selected
break;
}
}
if(colLoc == 0x0E) //1110 This means that First column is Selected
{
SerTX(keypad[rowLoc][0]);
}
else if(colLoc == 0x0D) // 1101 This means that Second column is Selected
{
SerTX(keypad[rowLoc][1]);
}
else if(colLoc == 0x0B) // 1011 This means that 3rd column is Selected
{
SerTX(keypad[rowLoc][2]);
}
else if(colLoc == 0x07) // 0111 This means that 4th column is Selected
{
SerTX(keypad[rowLoc][3]);
}
//lcdcmd(0xC0); //Second Row
//Check Columns and send the Data to the LCD Screen:-
if(colLoc == 0x0E) //1110 This means that First column is Selected
{
lcddata(keypad[rowLoc][0]);
}
else if(colLoc == 0x0D) // 1101 This means that Second column is Selected
{
lcddata(keypad[rowLoc][1]);
}
else if(colLoc == 0x0B) // 1011 This means that 3rd column is Selected
{
lcddata(keypad[rowLoc][2]);
}
else if(colLoc == 0x07) // 0111 This means that 4th column is Selected
{
lcddata(keypad[rowLoc][3]);
}
void lcdcmd(unsigned char value)
{
LcdData = value;
RS = 0;
RW = 0;
EN = 1;
Delay(1);
EN = 0;
}
void lcddata(unsigned char value)
{
LcdData = value;
RS = 1;
RW = 0;
EN = 1;
Delay(1);
EN = 0;
}
void Delay(unsigned int itime) // void Delay(unsigned int itime)
{
unsigned int i,j; //unsigned int i,j;
for(i=0;i<600;i++) //for(i=0;i<1275;i++)
for(j=0;j<itime;j++);
}
void SerTX(unsigned char x)
{
SBUF = x;
while(TI == 0);
Delay(10);
TI = 0;
}
void lcd_data(unsigned char item) // Function to send one byte data to LCD
{
LcdData = item;
RS= 1;
RW=0;
EN=1;
Delay(1);
EN=0;
return;
}
void lcd_data_string(unsigned char *str) // Function to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
Delay(10);
}
return;
}
void SMSString(unsigned char* text) //function to send SMS using GSM modem
{
while (*text)
{
SerTX(*text++);
}
}
void SerTX(unsigned char x)
{
SBUF = x;
while(TI == 0);
Delay(10);
TI = 0;
}
short column1 = 0x00; // Place to store values read from the port
// Reading a value.
// Assume your port is configured for inputs
PORT |= 0xFF; // Write to all
Delay(1); // Delay a very short time (long cables, longer delay)
column1 = PORT; // Read from all.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?