Discussion in "Project Doubts" started by    onyot    Nov 23, 2010.
Tue Nov 23 2010, 05:48 AM
#11
i can help you regarding LCD..... first make logic of wat u wanna do and write your code
Tue Nov 23 2010, 05:54 AM
#12
hi onyot.. this code is for displaying numbers on the 7 segment in every key pressed on the keypad.. get some idea here.. the keypad is 4x3 matrix


#include <REG51.h>


#define KEYPAD P1
#define display P3

void DelayMs(unsigned int) ;
unsigned char keypad[4][3]= { 1 , 2 , 3 ,
                              4 , 5 , 6 ,
			      			  7 , 8 , 9 ,
			      			15 , 0 , 15 } ;

void main()
{
unsigned char colloc,rowloc;

	while(1)
	{
		do
		{
			KEYPAD=0xF0;
			colloc=KEYPAD & 0xF0;
		}
    while(colloc ==0xF0);        // if any key pressed
	DelayMs(1);					 // some delay
	do
	{
	colloc=KEYPAD;
	colloc &=0xF0;
	}while(colloc==0xF0);		// to verify is really key pressed
    
		KEYPAD=0xFE;
		colloc=KEYPAD & 0xF0;
		if(colloc !=0xF0)
		{
			rowloc=0;
			goto next;
		}

		KEYPAD=0xFD;
		colloc=KEYPAD & 0xF0;
		if(colloc !=0xF0)
		{
			rowloc=1;
			goto next;
		}
		KEYPAD=0xFB;
		colloc=KEYPAD & 0xF0;
		if(colloc !=0xF0)
		{
			rowloc=2;
			goto next;
		}
				
		KEYPAD=0xF7;
		colloc=KEYPAD & 0xF0;
		rowloc=3;
		goto next;

next:			                                                                    
if (colloc==0xE0)
display=(keypad[rowloc][0]);
else if(colloc==0xD0)
display=(keypad[rowloc][1]);
else
display=(keypad[rowloc][2]);
}
}


//---------------------------------------
// Delay mS function
//---------------------------------------
void DelayMs(unsigned int count) 
{  // mSec Delay 11.0592 Mhz 
    unsigned int i;		       		
    while(count) {
        i = 115; 
		while(i>
0) i--;
        count--;
    }
}


Tue Nov 23 2010, 06:09 AM
#13
Mr. Romel Emperado, can I have the final code of the password program that you have?
Tue Nov 23 2010, 06:13 AM
#14
#include <REG51.h>

#define display P3
#define KEYPAD P1

sbit doorclose = P1^7;
sbit correct = P3^5;
sbit wrong= P3^4;
sbit key = P3^7;
void DelayMs(unsigned int);
void save (unsigned char);
void compare (void);

unsigned char keypad[4][3]= { '1', '2', '3',
                              '4', '5', '6',
			      			  '7', '8', '9',
			      			  '*', '0', '#'};

unsigned char displayb[4][3]= { 1 , 2 , 3 ,
                                4 , 5 , 6 ,
			      			    7 , 8 , 9 ,
                                0, 0 ,  0};

unsigned char code password[5]= "12345";
unsigned char user[30];	     //user is allowed to press 30 keys without entering						  
unsigned char q,a=0,z=0;
char t=1;
bit true;
char d;









void main(void)
{
unsigned char colloc,rowloc;



	while(1)
	{
	
		do
		{
			KEYPAD=0xF0;
			colloc=KEYPAD & 0xF0;
		}
    while(colloc ==0xF0);        // if any key pressed
	DelayMs(1);					 // some delay
	do
	{
	colloc=KEYPAD;
	colloc &=0xF0;
	}while(colloc==0xF0);		// to verify is really key pressed
    
		KEYPAD=0xFE;
		colloc=KEYPAD & 0xF0;
		if(colloc !=0xF0)
		{
			rowloc=0;
			goto next;
		}

		KEYPAD=0xFD;
		colloc=KEYPAD & 0xF0;
		if(colloc !=0xF0)
		{
			rowloc=1;
			goto next;
		}
		KEYPAD=0xFB;
		colloc=KEYPAD & 0xF0;
		if(colloc !=0xF0)
		{
			rowloc=2;
			goto next;
		}
				
		KEYPAD=0xF7;
		colloc=KEYPAD & 0xF0;
		rowloc=3;
		goto next;

next:			                                                                    
if (colloc==0xE0)
{
 key=0; 					// verifying that key is pressed
 DelayMs(145);
 key=1;
 display=((display & 0xf0) | (displayb[rowloc][0])); // display to 7 seg
 save(keypad[rowloc][0]);
}
else if(colloc==0xD0)
{
 key=0; 					// verifying that key is pressed
 DelayMs(145);
 key=1;
 display=((display & 0xf0) | (displayb[rowloc][1]));
 save(keypad[rowloc][1]);
}
else if(colloc==0xb0)
{
 key=0; 					// verifying that key is pressed
 DelayMs(145);
 key=1;
 display=((display & 0xf0) | (displayb[rowloc][2]));
 save(keypad[rowloc][2]);
}
DelayMs(100);	   // here this delay is important if this is less than 100ms then 
				   // controller understand 1 key as press 2 or 3 times becoz that 
				   //is fast as compaer o our pressing if u want to remove delay from here 
				   // then increse the above 1ms to 100 ms 
}
}

void save (unsigned char c)
{
 if(c=='*')
 {
  if(a!=0)
  a--;
  return;
 } 

 if(a==5 && c=='#')
 {
  a=0;
  compare();

	if(t==1)
	{
	  if(true==1) // if match ok
	  {
	   DelayMs(800);
       correct=0;
	   t=2;
       for(d=0; d<7; d++)	   // on and after 10 sec off nw keypad can't get data
       DelayMs(1000);	 // max delay u can get is DelayMs(65535) otherwise need looping for big delay
       correct=1;
	   z=0;
       a=0;           // start agian from 0 location of array
 
      }
	  else if(true==0)
	   goto error;

    }
	else if(t==2)
	  {
	    DelayMs(800);
	    doorclose=0;
		t=1;
	    for(d=0; d<5; d++)	 
        DelayMs(1000);	 
        doorclose=1;
	  }
  }
 
 else if((a>
5 && c=='#') || (a<5 && c=='#'))
  {
   error:
   for(q=0; q<5; q++)
   {
    wrong=0;
    DelayMs(420);
    wrong=1;
    DelayMs(420);
    a=0;
   }
   z=z+1;

       if(z==4)
        {
		 for(q=0; q<10; q++)
		  {
	       wrong=0;
		   DelayMs(20000);
           wrong=1;
		   z=0;
           DelayMs(420);
		   }
	    }
        a=0;
  }
else
 {
  user[a]=c;
  a++;

  if(a==30)		// if the user press 31 keys without entering it will automatically indicate an error
   {
    display=((display & 0xf0) | (displayb[3][1])); //brings a zero display on the seven segment
    goto error;	//redirect to error code
   }
 }
 
}	  //end of save



void compare (void)
{
 unsigned char b;
  for(b=0;b<5;b++)
   {

    if(user[b]==password[b])
     true=1;
    else
    {
     true=0;
     break;
    }
   }
}


//---------------------------------------
// Delay mS function
//---------------------------------------
void DelayMs(unsigned int count) 
{  // mSec Delay 11.0592 Mhz 
    unsigned int i;		       		
    while(count) {
        i = 115; 
		while(i>
0) i--;
        count--;
    }
}




Can you tell me, how is it work? I understand slightly but I don't know if it is correct.. So I need YOur help guys!


[ Edited Tue Nov 23 2010, 06:16 AM ]
Tue Nov 23 2010, 06:14 AM
#15
onyote try making your own code you have much time to do this.......here are many professionals who will help and guide you

Tue Nov 23 2010, 06:21 AM
#16
I don't know if I have that much time because as of now, I am here in an industrial plant having my on-the-job training, then, the work is very tiring.

Okay, I'll make a program and I will post it, maybe tomorrow...
Tue Nov 23 2010, 06:23 AM
#17


Mr. Romel Emperado, can I have the final code of the password program that you have?

onyot.josephian



hi onyot.. take it as your guide..and i hate to say bye to u guys i have a class... see u later

-----------------------------

onyot, where and what plant is that? is this your project or they require u this?

mirza,, kaon ta ug tae.. hehehe se me in FB lol


[ Edited Tue Nov 23 2010, 06:27 AM ]
 onyot.josephian like this.
Tue Nov 23 2010, 06:26 AM
#18
who knows how to make a keypad? just a simple keypad...
Tue Nov 23 2010, 06:32 AM
#19


who knows how to make a keypad? just a simple keypad...

onyot.josephian



there are many keypad schematic in www.google.com choose keypad that suite to your need..
Tue Nov 23 2010, 06:46 AM
#20
Is it okay to use an Ordinary switch (Push button that is NO)?

Get Social

Information

Powered by e107 Forum System

Conversation

Thu Nov 21 2019, 12:30 PM
raj2555
how to interface 8051 microcontroller with NRF24L01+ module
ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.
ExperimenterUK
Thu Jul 11 2019, 07:55 PM
@ramos https://www.theengineeringprojects.com/2017/09/l298-motor-driver-library-proteus.html

Downloads

Comments

nabiha_anaya
Sun Dec 08 2019, 09:16 AM
ananyagupta
Tue Dec 03 2019, 07:53 AM
wells
Mon Nov 25 2019, 08:25 PM
auwal
Tue Nov 19 2019, 03:13 PM
ANKITPATEL
Mon Nov 18 2019, 11:00 AM
Casmir
Wed Nov 13 2019, 06:25 AM
DeepakBGattani
Mon Nov 11 2019, 01:31 PM
Jeanbusatta
Sun Nov 10 2019, 04:42 AM

Online

Guests: 35, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38108
Newest member: nabiha_anaya
Forum Activity
ilylily07 Avatar
Posted By ilylily07
Sun Dec 08 2019, 01:24 PM
Hi .im humbly ask for your advice as i wrongly pur...
nabiha_anaya Avatar
Posted By nabiha_anaya
Sun Dec 08 2019, 09:19 AM
My teacher assign me a project on "voice control h...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Nov 29 2019, 04:24 AM
" Is it possible to interface a fingerprint scanne...
ilylily07 Avatar
Posted By ilylily07
Thu Nov 28 2019, 03:50 PM
You will not find any code for an 8051 as no one w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 26 2019, 05:44 PM
You will not find any code for an 8051 as no one w...
ilylily07 Avatar
Posted By ilylily07
Tue Nov 26 2019, 04:13 AM
I tracked down a OV7670 data sheet.The OV7670 puts...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 26 2019, 12:08 AM
I tracked down a OV7670 data sheet.The OV7670 puts...
ilylily07 Avatar
Posted By ilylily07
Mon Nov 25 2019, 04:38 PM
The 8051 has too little memory to do anything us...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 19 2019, 10:44 PM
The 8051 has too little memory to do anything us...
ilylily07 Avatar
Posted By ilylily07
Mon Nov 18 2019, 09:54 AM
0v7670 camera interfacing with stc 8051.using asse...