CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

applications of lcd

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
GSHB0760



Joined: 26 Feb 2009
Posts: 3

View user's profile Send private message

applications of lcd
PostPosted: Tue Mar 03, 2009 10:30 am     Reply with quote

Hi everybody. I have worked about password lock program with LCD and keypad. But I can not do things what I want. I am using pic16f877. I can see the number on LCD one by one but I wanted can write them side by side. For example I will pass a password and I will see four stars on lcd and will should save on EEPROM memory and will call the password again. Thanks in advance.
Code:

#define use_portb_lcd TRUE
#include <lcd.c>
#define sut1 pin_d0
#define sut2 pin_d1
#define sut3 pin_d2
#define sut4 pin_d3
#define sat1 pin_d4
#define sat2 pin_d5
#define sat3 pin_d6
#define sat4 pin_d7

char tus;int sonuc;
char keypad_oku()
{
output_d(0x00);

output_high(sat1);
if (input(sut1))
{delay_ms(20); tus=1;}
if (input(sut2))
{delay_ms(20); tus=2;}
if (input(sut3))
{delay_ms(20); tus=3;}
if (input(sut4))
{delay_ms(20); tus=0xA;}
output_low(sat1);
output_high(sat2);
if (input(sut1))
{delay_ms(20); tus=4;}
if (input(sut2))
{delay_ms(20); tus=5;}
if (input(sut3))
{delay_ms(20); tus=6;}
if (input(sut4))
{delay_ms(20); tus=0xB;}
output_low(sat2);
output_high(sat3);
if (input(sut1))
{delay_ms(20); tus=7;}
if (input(sut2))
{delay_ms(20); tus=8;}
if (input(sut3))
{delay_ms(20); tus=9;}
if (input(sut4))
{delay_ms(20); tus=0xC;}
output_low(sat3);
output_high(sat4);

if (input(sut1))
{delay_ms(20); tus=0xE;}
if (input(sut2))
{delay_ms(20); tus=0;}
if (input(sut3))
{delay_ms(20); tus=0xF;}
 if (input(sut4))
{delay_ms(20); tus=0xD;}
output_low(sat4);

return tus;
}

int tus_tarama()
{output_d(0x00);

output_high(sut1);
if((((sut1)|(sut2))|(sut3))|(sut4))
{delay_ms(20);sonuc=1;}
output_low(sat1);
output_high(sat2);
if((((sut1)|(sut2))|(sut3))|(sut4))
{delay_ms(20);sonuc=1;}
output_low(sat2);
output_high(sat3);
if((((sut1)|(sut2))|(sut3))|(sut4))
{delay_ms(20);sonuc=1;}
output_low(sat3);
output_high(sat4);
if((((sut1)|(sut2))|(sut3))|(sut4))
{delay_ms(20);sonuc=1;}
output_low(sat4);
return sonuc;
}

void main ()
{
set_tris_b(0x01);
set_tris_d(0x0f);
lcd_init();
printf(lcd_putc,"\fbasilan tus=");


while(1)
{lcd_send_byte(0,0xc4);
if(tus_tarama()){

printf(lcd_putc,"%d%d%d%d",keypad_oku(),keypad_oku(),keypad_oku(),keypad_oku());
}
else{
printf(lcd_putc,"\nenter the password...");}}}
Sydney



Joined: 13 Feb 2009
Posts: 71

View user's profile Send private message

PostPosted: Tue Mar 03, 2009 12:36 pm     Reply with quote

Code:
if(input(sut1)||input(sut2)||input(sut3)||input(sut4))


The easiest way is probably to save the keypresses in a string, increment a pointer to the string, and update the display every keypress.

Here you could do

Code:
if (input(sut1)) {
   delay_ms(20);
   return 1;
}


same for the other function, unless you specifically want the keypress priority in the current order.
GSHB0760



Joined: 26 Feb 2009
Posts: 3

View user's profile Send private message

PostPosted: Tue Mar 03, 2009 1:18 pm     Reply with quote

Thanks for your reply. But my problem is about the program's algorithm.
I can press the keys. I want to write password that has four-digits.
When I press the keypad, I want to show password as four digits.
Thanks in advance
Sydney



Joined: 13 Feb 2009
Posts: 71

View user's profile Send private message

PostPosted: Tue Mar 03, 2009 3:06 pm     Reply with quote

Yes I understand that, but your code is very basic, there is no switch debouncing, no repeat handling (the keys will repeat every 20ms), and it has a few simple errors.

There are already keypad drivers in the code forum, and even this example http://www.ccsinfo.com/forum/viewtopic.php?t=28022&start=14 which with a few modifications will do exactly what you want.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group