[51] Query regarding keypad scrolling

Status
Not open for further replies.

poojaghorpade

Newbie level 4
Joined
Feb 24, 2014
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
71
I am using 4*4 matrix keypad.I want to scroll messages on LCD. for
example if first msg is displayed on lcd then after pressing the
'enter key' that first msg must be replaced by second on... and this
should continue until i press 'enter key'.. for this i am writing code
but not getting the result...will you plz suggest me a code to run
this
 

Which Compiler and micro-controller are you using? What is its Fosc?

You want particular line of display to scroll or is it ok if all the lines of LCD scroll at the same time?

Sample moving display project with two different texts. Proteus simulation attached.
 

Attachments

  • LCD Scroll.rar
    10.1 KB · Views: 69
Last edited:

I am using P89LV51.
I will go through your attached file.
the display must scroll if i press enter key. i searched a lot on net and also tried myself but i m not getting it in a perfect way. actually what happens is if i m writing a condition that column must be 1110 and row must be 1110 so that enter key seems to b pressed...but instead it shows that 4 8 and enter are going low. i know how to interface 4*4 matrix keypad so tat it displays whatever pressed on keypad..but i am unable to write code the code further

- - - Updated - - -

the attachment you have forwarded is unable to open in my pc.. will you please send me tat in notepad or keil format..

- - - Updated - - -

the attachment you have forwarded is unable to open in my pc.. will you please send me tat in notepad or keil format..
 

Try mikroC PRO 8051 Demo Compiler. It generates .hex file for code less than 2 KB. It has LCD and Keypad libraries. It will be easy for you. Download the compiler from mikroe.com

I have checked and the compiler supports AT89LV51.

- - - Updated - - -

The attached file should be extracted using winrar. You will get two files. .hex file and .dsn file. .dsn file is the Proteus simulation file. Open it using Proteus 7.10 and load the .hex file to micro in Proteus and simulate.
 
Actually I am new to all these softwares..

I dont have idea about proteus 7.10....

I am using C compiler...
sorry if i am confusing you but i am really confused about that program

- - - Updated - - -

#include<stdio.h>
#include <reg51.h>
#include<string.h>
#define col P3 //keypad connected to P3

sbit sda=P1^1;
sbit sclk=P1^0;

sbit col0 = P3^0 ; //column 1
sbit col1 = P3^1 ; //column 2
sbit col2 = P3^2 ; //column 3
sbit col3 = P3^3 ; //column 4

sbit row0 = P3^4;
sbit row1 = P3^5;
sbit row2 = P3^6;
sbit row3 = P3^7;

sbit rs = P2^2;
sbit rw = P2^1;
sbit en = P2^0;
sbit busy = P0^7;

void lcdready();
void send_to_mem(char s_address, char s_data);
void start_s_eeprom();
void send_byte_s_eeprom(char);
unsigned char i2c_read();
void stop_s_eeprom();
void send_to_mem(char, char);
void wait();
void acknowledge();
int lcdcmd(unsigned int a);
int lcddata(unsigned char a);
int delay(unsigned int i);
int display(unsigned char msg[]);
unsigned char code msg1[] = {"Press key"};
unsigned char code msg2[] = {"Key pressed"};



void send_to_mem(char s_address, char s_data)
{

start_s_eeprom(); // sending start condition to eeprom
send_byte_s_eeprom(0XA0); // A0 = 10100000 = sending device address word for write
acknowledge();
send_byte_s_eeprom(s_address); // sending data address
acknowledge();
send_byte_s_eeprom(s_data); // sending data
acknowledge();
stop_s_eeprom(); // sending stop condition to eeprom
acknowledge();
return;

}








unsigned char get_from_mem(char s_address)
{
unsigned char EEPROM1_DATA ;

start_s_eeprom(); // sending start condition to eeprom
send_byte_s_eeprom(0xA0); // sending A0 = 10100000 = device address word for write
acknowledge();
send_byte_s_eeprom(s_address); // sending data address
acknowledge();


start_s_eeprom();
send_byte_s_eeprom(0xA1); // sending A1 =10100001 = device adress word for read
acknowledge();
EEPROM1_DATA = i2c_read(); // sending data
acknowledge();
stop_s_eeprom(); // sending stop condition to eeprom
acknowledge();


return(EEPROM1_DATA);
}






void send_byte_s_eeprom(char s_byte)
{
char temp = s_byte;
char i ;


for(i = 7 ; i >= 0 ; i--)
{

temp = s_byte;
temp = temp >> i;
temp = temp & 0X01;


if(temp == 0)
sda = 0;
else
sda = 1;

sclk = 1;
wait();
sclk = 0;

}
return;
}


unsigned char i2c_read()
{
char ee_result;
unsigned int counter;
ee_result=0;
sda=1;
sclk=0;
for(counter=0;counter<8;counter++)
{
sclk=1;
while(!sclk){}
wait();
ee_result<<=1;
if(sda){ee_result|=0x01;}
sclk=0;
wait();

}
return(ee_result);
}





void start_s_eeprom()
{
sda = 1;
sclk = 1;
wait();
sda = 0;
sclk = 0;
return;

}



void stop_s_eeprom()
{
sda = 0;
sclk = 1;
wait();
sda = 1;
sclk = 0;
return;
}






void acknowledge()
{


sclk = 1;
wait();
sclk = 0;
return;
}


int lcdcmd(unsigned int a)
{
lcdready();
P0 = a;
rs = 0;
rw = 0;
en = 1;
delay(1);
en = 0;
return;
}



int lcddata(unsigned char a)
{
lcdready();
P0 = a;
rs = 1;
rw = 0;
en = 1;
delay(1);
en = 0;
return;
}


void lcdready()
{
busy=1;
rs=0;
rw=1;
while(busy==1)
{
en=0;
delay(1);
en=1;
}
return;
}

int display(unsigned char msg[])
{
unsigned char i=0;
while(msg!='\0')
{
lcddata(msg);
i++;
}
i=0;
return;
}


int delay(unsigned int i)
{
unsigned int x,y ;

for(x=0;x<i;x++)
{
for(y=0;y<100;y++);
}
}

void main()
{ unsigned char temp1,row;
lcdcmd(0x38);
lcdcmd(0x0e);
lcdcmd(0x01);
lcdcmd(0x06);
display (msg1);
}



here is my code.....
I am not getting how to work further.. plz help me out
 

You didn't reply to my PM. When PM notification pops up click OK and then cancel.
 

if this is your complete code , you are not scanning your keypad at all, and you are not telling what to do when you press Enter Key.

use code tags while posting it makes easy to read !
 

Read 8051 Microcontroller and Embedded System Using C and Assembly Language by Muhammad Ali Mazidi.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…