EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / MAX 232 IC is already

MAX 232 IC is already

|

Microcontroller › 8051 › Intefacing Problem in my RFID module and its CODING….. › MAX 232 IC is already

March 25, 2013 at 12:08 pm #9367
abhilash
Participant

MAX 232 IC is already connected in my module.. Do i need to connect another max232 IC to interface with my at89c52 microcontroller..? Serial port is also connected. plz tell me how to interface with Microcontroller.

 

my program is like this. Is there any correction needed..?

 

// Program to interface controller with controller
#include<reg52.h>
#include<stdio.h>
#include<string.h>
#define port P3     // command port for lcd
#define dataport P0 //dataport for lcd
#define key P1        // port for keypad
#define sec 100
sbit rs =  port^7;
sbit rw = port^6;
sbit e = port^5;
sbit col1=key^4;
sbit col2=key^5;
sbit col3=key^6;
sbit row1=key^0;
sbit row2=key^1;
sbit row3=key^2;
sbit row4=key^3;

  sbit buzzer_pin=P2^1;        //  Buzzer pin to sound the buzzer.
sbit lock_output=P2^7;
int check=0;
int digit[4]={0,0,0,0};
int dig_one=3;
int dig_two=9;
int dig_three=0;
int dig_four=7;
 int i,count=0;
  unsigned char card_id[12];
void delay(unsigned int msec) //  time delay function
{
int i,j;
for(i=0;i<msec;i++)
 for (j=0;j<1275;j++);
 }
 void lcdcmd(unsigned char item) // function to send lcd command
 {
       dataport=item;
  rs=0;
 rw=0;
 e=1;
 delay(10);

 e=0;
 return;
 }

 void lcddata(unsigned char item) //function to send data to the lcd
{
     dataport=item;
rs=1;
rw=0;
e=1;
delay(10);

e=0;
return;
}
void lcddatastring(unsigned char *str) // function to display on lcd string thru pointer by reading 1 by 1
 {
 int i=0;
 while(str!=’’)
 {
 lcddata(str
);
 i++;
 delay(10);
 }
 return;
 }
 void lcd()
 {

lcdcmd(0x38);  // for using 8-bit 2 row mode of LCD
lcdcmd(0x0E);  // turn display ON for cursor blinking
delay(10);
lcdcmd(0x01);  //clear screen
delay(10);
lcdcmd(0x06);  //display ON
delay(10);
lcdcmd(0x80);  // bring cursor to position  of line 1
delay(1);                   ///checkkkkk
}
   void recieve()  //funcn to recive data serially from RS232
  {
       unsigned char k;
        for (k=0;k<12;k++)
       {
        while(RI==0);
        card_id[k]=SBUF;    // storing in at89c51’s SBUF registor
        RI=0;     //indicates byte(8 bits in register)has been received & shud b Picked
        }
    }
   void code_check()
   {
     if (i<=3)
       {
       switch((i+1))
       {
       case 1: {
       if (dig_one==digit[0])
      {
       check=check+1;
      }
      break;
      }
       case 2: {
       if (dig_two==digit[1])
      {
       check=check+1;
      }
      break;
      }
     case 3: {
       if (dig_three==digit[2])
      {
       check=check+1;
      }
      break;
      }
      case 4: {
       if (dig_four==digit[3])
      {
       check=check+1;
      }
      break;
      }
     }
     }  //if ( i==3){ans();
   }
void ans()                                           // gives the answer
{
  if (check==3)      // checkkkkk may be >3
  {
     lcd();
  lcddatastring(“LOCK OPEN”);
  lock_output=1;
  delay(200);
  }
  else
   {
   lcd();
  lcddatastring(“WrongPassword”);
   lock_output=0;
  count=count+1;
  delay(500);
   }
 

}
void start_buzr()
{
while(1)
     {
    buzzer_pin=0;
    delay(100);
    buzzer_pin=1;
    delay(100);
     }
}

void display(int a) // display function    for lcd
{
switch(a)
{
  case 1:lcd();
  lcddatastring(“1”);
  delay(30);
  digit
=1;
  code_check();
   break;
  case 2:lcd();
  lcddatastring(“2”);
  delay(30);
  digit
=2;
   code_check();
    break;
  case 3:lcd();
  lcddatastring(“3”);
  delay(30);
  digit
=3;
   code_check();
    break;
  case 4:lcd();
  lcddatastring(“4”);
  delay(30);
  digit
=4;
   code_check();
    break;
  case 5:lcd();
  lcddatastring(“5”);
  delay(30);
  digit
=5;
   code_check();
    break;
  case 6:lcd();
  lcddatastring(“6”);
  delay(30);
  digit
=6;
   code_check();
    break;
  case 7:lcd();
  lcddatastring(“7”);
  delay(30);
  digit
=7;
   code_check();
    break;
  case 8:lcd();
  lcddatastring(“8”);
  delay(30);
  digit
=8;
   code_check();
    break;
  case 9:lcd();
  lcddatastring(“9”);
  delay(30);
  digit
=9;
   code_check();
    break;
  case 0:lcd();
  lcddatastring(“0”);
     delay(30);
  digit
=0;
   code_check();
    break;
  case 10:lcd();
  lcddatastring(“*”);
    break;
  case 12:lcd();
  lcddatastring(“#”);
    break;
}
}
void check_col1() //   fuction for checking column 1
{
row1=row2=row3=row4=1;
row1=0;
if(col1==0)
display(1);
row1=1;
row2=0;
if(col1==0)
display(4);
row2=1;

row3=0;
if(col1==0)
display(7);
row3=1;

row4=0;
if(col1==0)
display(10);
row4=1;
 }
 void check_col2()
 {
 row1=row2=row3=row4=1;
row1=0;
if(col2==0)
display(2);
row1=1;
row2=0;
if(col2==0)
display(5);
row2=1;
row3=0;
if(col2==0)
display(8);
row3=1;
row4=0;
if(col2==0)
display(0);
row4=1;
 }
 void check_col3()
  {
 row1=row2=row3=row4=1;
row1=0;
if(col3==0)
display(3);
row1=1;
row2=0;
if(col3==0)
display(6);
row2=1;
row3=0;
if(col3==0)
display(9);
row3=1;

row4=0;
if(col3==0)
display(12);
row4=1;
 }
 void main()
 {
  int l;
   // Make the port as output port
   
  TMOD=0X20; // ENABLES MODE 2 OF TIMER 1
  TH1=0XFD;
  SCON=0X50;
  TR1=1;  //   triggering timer1;
   lcd();  ///CHECKKKKKK
   lcdcmd(0x81);        //Place cursor to second position of first line
 lcddatastring(“RFID BANKING SYSTEM” );
 delay(100);
 lcd();  ///CHECKKKKKK
 lcddatastring(“UNIQUE CARD ID:” );
 delay(200);
 while(1)
 {
 recieve();
 lcdcmd(0xC1);      // place the cursor to the second position of the second line
   for(l=0;l<12;l++)
   {
   lcddata(card_id[l]);
   }
 }
 delay(100);
 lcd();  ///CHECKKKKKK
   lcdcmd(0x81);        //Place cursor to second position of first line
 lcddatastring(“ENTER PASSWORD:” );
 check=0;
 while(col1==1 && col2==1 && col3==1);
  for(i=0;i<4;i++)
  {
   delay(100);
   lcdcmd(0xc4+i);
 col1=col2=col3=1;          //input port
 while(1)
  {
 row1=row2=row3=row4=0;
 if(col1==0)
 check_col1();
  else
  if(col2==0)
  check_col2();
  else
if (col3==0)
check_col3();
  }
   if (count>3)
   lcd();
  lcddatastring(“Unauthorised”);
  start_buzr();// checkkkk for count 3 attempt to give alarm
  }
 code_check();
 ans();
}

 

 

 

 

 

 I am not sure whether this code is correct or not..

RSS Recent Posts

  • Do i need a buffer? February 7, 2026
  • FM Radio circuits February 7, 2026
  • wall transformer polarity February 7, 2026
  • To buy or DIY? February 7, 2026
  • engineering analysis of shmidth trigger without simulation February 6, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise