- #include <AT89X51.H>
-
#define EE_SCL P1_0
-
#define EE_SDA P1_1
-
#define LCD_E P1_7
-
#define LCD_RW P1_6
-
#define LCD_RS P1_5
-
#define LCD_DATA P3
-
#define buzz P0_3
-
#define led P1_2
-
void cmnwrt(int);
-
void datawrt(char);
-
char keypad_refresh();
-
void init();
-
void delay(unsigned i);
-
void get_sntnc(char *);
-
void print_msg(char*,char);
-
void EE_write(unsigned int, char);
-
char EE_read(unsigned int);
-
void EE_strt();
-
void EE_stop();
-
char EE_shin();
-
void EE_shout(char);
-
//----------------------------------------
-
//----------------------------------------
-
int main(){
-
char tmp[17],i,j;
-
init();
-
cmnwrt(0x80);
-
led=1;
-
while(1){
-
if(EE_read(0)!='p'||EE_read(1)!='='){
-
np:
-
cmnwrt(1);
-
print_msg("Enter new pass:\0",0x80);
-
get_sntnc(tmp);
-
EE_write(0,'p');
-
EE_write(1,'=');
-
for(i=0;tmp[i];i++)
-
EE_write(i+2,tmp[i]);
-
EE_write(i+2,0);
-
}
-
rpa:
-
cmnwrt(1);
-
print_msg("Enter the pass:\0",0x80);
-
get_sntnc(tmp);
-
for(i=0,j=0;;i++){
-
if(tmp[i]!=EE_read(i+2)){
-
j=-1;
-
break;
-
}
-
if(!tmp[i])
-
break;
-
}
-
cmnwrt(1);
-
if(j==-1)
-
{
-
print_msg("Pass is wrong!\0",0x80);
-
led=1;
-
buzz=1;
-
delay(5000);
-
buzz=0;
-
goto rpa;
-
}
-
else
-
{
-
print_msg("Pass is right!\0",0x80);
-
led=0;
-
buzz=0;
-
delay(5000);
-
led=1;
-
}
-
cmnwrt(1);
-
print_msg("*=change pass\0",0x80);
-
print_msg("#=back\0",0xc0);
-
ka:
-
do
-
i=keypad_refresh();
-
while(i==-1);
-
if(i==0x3a)
-
goto np;
-
else if(i==0x3c)
-
goto rpa;
-
else
-
goto ka;
-
}
-
}
-
//------------------------------------
-
//------------------------------------
-
void print_msg(char *msg, char line){
-
char i;
-
cmnwrt(line);
-
for(i=0;*(msg+i);i++)
-
datawrt(*(msg+i));
-
}
-
//------------------------------------
-
//------------------------------------
-
char keypad_refresh(){
-
char tmp,row,cl;
-
P2 = 0xf0;
-
if(!P2_4)
-
row = 0;
-
else if(!P2_5)
-
row = 1;
-
else if(!P2_6)
-
row = 2;
-
else if(!P2_7)
-
row = 3;
-
else
-
return -1;
-
P2 = 0xff;
-
P2 = 0x0f;
-
if(!P2_2)
-
cl = 0;
-
else if(!P2_1)
-
cl = 1;
-
else if(!P2_0)
-
cl = 2;
-
else
-
return -1;
-
tmp = row*3+cl+1;
-
if(tmp == 11)
-
tmp = 0;
-
return tmp|0x30;
-
}
-
//--------------------------------------------------
-
//--------------------------------------------------
-
void get_sntnc(char *str) {
-
char i,j,z;
-
for(i=0;i<17;i++)
-
*(str+i)=0;
-
i=0;
-
while(1){
-
cmnwrt(0xc0);
-
for(z=0;z<16;z++)
-
if(*(str+z))
-
datawrt(*(str+z));
-
else
-
datawrt(' ');
-
delay(70);
-
do
-
j = keypad_refresh();
-
while(j==-1);
-
if(j==0x3c){
-
*(str+i)=0;
-
break;
-
}
-
else if(j==0x3a){
-
if(i>0){
-
i--;
-
*(str+i)=0;
-
}
-
}
-
else{
-
if(i<=15){
-
*(str+i)=j;
-
i++;
-
}
-
}
-
}
-
}
-
//--------------------------------------------------
-
//--------------------------------------------------
-
void init() {
-
int i;
-
P0=P1=P2=P3=0;
-
//initialize LCD
-
LCD_RS = 0;
-
LCD_RW = 0;
-
delay(30);
-
cmnwrt(0x3f);
-
delay(20);
-
cmnwrt(0x3f);
-
delay(10);
-
cmnwrt(0x3f);
-
delay(5);
-
cmnwrt(0x38);
-
cmnwrt(0x01);
-
cmnwrt(0x0c);
-
//initialize EEPROM
-
EE_SDA = 1;
-
for(i=0;i<10;i++) {
-
EE_SCL = 1;
-
i=i; //delay
-
EE_SCL = 0;
-
}
-
}
-
//--------------------------------------------------
-
//--------------------------------------------------
-
void delay(unsigned i) {
-
TMOD = 1;
-
for (;i>0;i--) {
-
TH0 = 0xFc; //0xFFFF - 0xFc17 = 1000 (decimal) -> 1ms for 12MH crystal
-
TL0 = 0x17;
-
TR0 = 1;
-
while(!TF0);
-
TR0 = 0;
-
TF0 = 0;
-
}
-
}
-
//--------------------------------------------------
-
//--------------------------------------------------
-
void cmnwrt(int cmn) {
-
LCD_DATA = cmn;
-
LCD_RS = 0;
-
LCD_RW = 0;
-
LCD_E = 1;
-
LCD_E = 0;
-
delay(2);
-
}
-
void datawrt(char ch) {
-
LCD_DATA = ch;
-
LCD_RS = 1;
-
LCD_RW = 0;
-
LCD_E = 1;
-
LCD_E = 0;
-
delay(2);
-
}
-
//---------------------------------------------------
-
//---------------------------------------------------
-
//Write into EEPROM
-
void EE_write(unsigned int addr, char dta){
-
char chtmp;
-
CY = 0;
-
EE_strt();
-
EE_shout(0xA0);
-
chtmp=addr>>8;
-
EE_shout(chtmp);
-
chtmp=addr;
-
EE_shout(chtmp);
-
EE_shout(dta);
-
EE_stop();
-
delay(13);
-
}
-
//Reading from EEPROM
-
char EE_read (unsigned int addr) {
-
char chtmp;
-
CY=0;
-
EE_strt();
-
EE_shout(0xA0);
-
chtmp=addr>>8;
-
EE_shout(chtmp);
-
chtmp=addr;
-
EE_shout(chtmp);
-
EE_strt();
-
EE_shout(0xA1);
-
chtmp=EE_shin();
-
EE_stop();
-
return chtmp;
-
}
-
//Start
-
void EE_strt() {
-
EE_SDA=1;
-
EE_SCL=1;
-
EE_SDA=0;
-
EE_SCL=0;
-
}
-
//Stop
-
void EE_stop() {
-
EE_SCL=0;
-
EE_SDA=0;
-
EE_SCL=1;
-
EE_SDA=1;
-
}
-
//Shift out
-
void EE_shout(char sho) {
-
unsigned char i,j;
-
for(j=0,i=0;i<8;i++) {
-
j/=2;
-
if(!j)
-
j=128;
-
if(sho&j)
-
CY=1;
-
else
-
CY=0;
-
EE_SDA=CY;
-
EE_SCL=1;
-
j=j; //delay
-
EE_SCL=0;
-
}
-
EE_SDA=1;
-
EE_SCL=1;
-
j=j; //delay
-
CY=EE_SDA;
-
EE_SCL=0;
-
}
-
//Shift in
-
char EE_shin() {
-
char i,shi = 0;
-
EE_SDA = 1;
-
for(i=0;i<8;i++) {
-
CY=0;
-
shi<<=1;
-
EE_SCL=1;
-
i=i;
-
CY=EE_SDA;
-
EE_SCL=0;
-
if(CY)
-
shi++;
-
}
-
EE_SDA=1;
-
EE_SCL=1;
-
i=i; //delay
-
EE_SCL=0;
-
return shi;
-
}
5 1309
May be you could explain a little further. The error occurs when the code runs, when it links, or when it compiles?
What is the code supposed to do? There are no comments whatever.
I suggest that you step through this code using your debugger. Since you know what you are looking for, and I don't, you doing the debugging will get results instead of me.
Also, what is the error message?
(Only the first letter appears in the title of your post.)
there are no syntax errors.
The program stores the newly entered password and must display the message" pass is right" when the password again entered is correct but the program always displays "pass is worng" message only.
After much debugging only i have posted here.
code must check for the password with the previously entered But the code only displays "pass is wrong" for every correct password also.
Your code to make the decision if the password is right or wrong is:
-1 is an int an j is a char.
Start by making j an int.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: PiEmme |
last post by:
On a Linux server a MySql db is installed.
I was able to run mysql and mysqladmin without entering user and
password, at first.
Later both user and password have become required. Probably after...
|
by: splicemix |
last post by:
Hi all,
I have recently set up a Drupal website. I am a beginner. My shared
host server does not allow nobody@localhost to send emails, and
prevents access to php.ini, so I spent some time...
|
by: tsalikivenu |
last post by:
Hi
i have problem with loading digital certificates.i am currently using asp.net 2003.i have installed wse2.0
here is my code..i want it to load digital certficates to list box..it is...
|
by: icy111 |
last post by:
Hi All,
I need to generate excel files with password protected in ASP?
Kindly help.
Thanks in Advance.
Regards
icy111
|
by: abetown3 |
last post by:
Hello. I'm having data entry problems with a database I've created. I'm working in Access 2003 although the db was created in 2000 format. When data entry first began the db allowed for multiple...
|
by: Claudia Fong |
last post by:
In my windows form I have a comboBox and a textBox. When I try to write
something in the
textBox it shows me the error message below:
Attempting managed execution inside OS Loader lock. Do not...
|
by: Porkie999 |
last post by:
hi i have used this code in my website but have a problem with the header parts where is the problem the error is
<?php
$myusername = "myusername";
$mypassword = "mypassword";
$areaname...
|
by: rando1000 |
last post by:
I have an automated e-mail process that recently broke due to some security we implemented that requires a password for sendmail. Here's my code:
Set iMsg = CreateObject("CDO.Message")
...
|
by: johnb773 |
last post by:
I have a .txt file that has some PHP coding (<?php echo setUrlVariables(); ?>) embedded into it.
It worked fine (the variables actually worked) when I had my PHP file 'include("myfile.txt")'...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |