Showing posts with label 8051 projects. Show all posts
Showing posts with label 8051 projects. Show all posts

Tuesday, April 24, 2012

RFID based Attendance system using 8051- with easy AUTOMATIC FILE generation facility


watch the video for explanation of the project

#include
 #include<string.h>
 #include "lcd_display4bit.h"

 #define TOTAL 5

 void serial_init();
 void serial_txS(char *);
 void serial_tx(char);
 void checkID();
 void printOnTerminal();
 short int checkTodaysAttd(int);

 sbit ON=P1^0;
 sbit RESET=P1^1;
 sbit result=P1^2;
 sbit IR_Tx=P1^3;
 sbit IR_Rx=P1^4;
 sbit Reset_Todays_Attendence=P1^5;
 
struct details
 {
   char *name;
   char id[4];
   int count;
 }emp[TOTAL]={{"phanindra", "437p", 0},
          {"nayak",     "455n", 0},
          {"anilKumar", "414a", 0},
          {"gowtham",   "456g", 0},
          {"chaitu",    "449c", 0}};

 char recieved_id[4]={0};
 int i, no_of_stu=0, todays_count=0;
 int todays_ids[4]={0};
 short int access=0, gotID=0;

 void serial() interrupt 4
 {
   EA=0;
     for(i=0;i<4;i++)
      {
        while(RI==0);
        recieved_id[i]=SBUF;
        RI=0;
      }
      gotID=1;
   EA=1;
 }

//***********************************------
 void main()
  {
    ON=RESET=result=1;
    rs=en=0;
    P2=0x00;
    IR_Rx=1;
    IR_Tx=0;
    EA=1;
    ES=1;
    serial_init();
    lcd_init();

super:    
   while(1)
     {
     IR_Tx=0;
     lcd_cmd(0x01);

       while(!ON)
       { 
        lcd_cmd(0x01);
        IR_Tx=1;
         while(!(IR_Rx==1))
         {
          lcd_cmd(0x01);
          lcd_dataS("ID please");
          
          while(gotID==0)   //wait until any card is shown
            if(ON==1) goto super;
          
          checkID();    
         }
       }
      /////////////////////////
       while(!result)
        {
          for(i=0;i<=TOTAL;i++)
          {
            lcd_cmd(0x01);
            lcd_dataS(emp[i].name);
            lcd_cmd(0xc0);
            lcd_data_int(emp[i].count);
            delay_msec(500);
          }
        }
      ////////////////////////

       while(! Reset_Todays_Attendence)
        {
          for(i=0;i'\0';

          todays_count=0;
          lcd_cmd(0x01);
          lcd_dataS("todays attd rst");
          delay_msec(100);
        }
      ///////////////////////
      }    //end of super loop
 } //end of main

//*************************************

void checkID()
{
  access=0;               //like a flag
  lcd_dataS(recieved_id);
    for(i=0;iif(( strcmp(emp[i].id , recieved_id) )==0)
     { 
      if(checkTodaysAttd(i)) 
          {
              access=1;
              lcd_cmd(0x01);
              lcd_dataS("welcome");
              lcd_cmd(0xc0);
              lcd_dataS(emp[i].name);
              emp[i].count++;

            todays_ids[todays_count]=i+1;
                 todays_count++;

            delay_msec(400);
              printOnTerminal();
            gotID=0;
              break;
          }
       else
         {
           lcd_cmd(0x01);
           lcd_dataS("your turns over");
           gotID=0;
           delay_msec(400);
         }
     }
    }


   if(access==0)
    {
        lcd_cmd(0x01);
        lcd_dataS("access denied");
        delay_msec(100);
        gotID=0;
    }    
}

short int checkTodaysAttd(int id)
{
  short int d;
  for(d=0;dif(id==(todays_ids[d]-1))
    return 0;    //return 0 if specific ID has already been
  }               //counted for today.
  return 1;
}

void printOnTerminal()
{ EA=0;
  serial_tx('\r');
  serial_tx('\n');
  serial_txS(emp[i].name);
  serial_tx(' ');
  serial_txS(emp[i].id);
  serial_tx(' ');
  serial_tx(emp[i].count+48);
  EA=1;
}  

void serial_init()
{
  TMOD=0x20;
  TH1=0xfd;
  SCON=0x50;
  TR1=1;
}

void serial_txS(char *p)
{
  while((*p)!='\0')
  {
    SBUF=*p;
    while(TI==0);
    TI=0;
    p++;
  }
}

void serial_tx(char x)
{
  SBUF=x;
  while(TI==0);
  TI=0;
} 

Thursday, March 8, 2012

Time Display On LCD using 8051 Microcontroller

/* Displaying time on LCD using microcontroller
    To get 1sec delay timer(16bit mode) should overflow 14 times, 
 but instead i have used only 11 times because I 
 have counted prograam instructions delays and 11 
 times will increment exactly 1sec.   

 algorithm: wait in the loop for INCREMENT to be 1
      INCREMENT will be 1 only when the timer0
      overflows for 11 times(spcifically for my program)
      see my program logic, you can understand  */


#include<reg51.h>
#include "lcd_display4bit.h"

sbit ON=P1^0;
sbit SET=P1^1;
sbit incr_hrs=P1^2;
sbit incr_min=P1^3;
sbit set_hrs=P1^5;
sbit set_min=P1^4;

int sec,min,hrs;
int min_value=0,hrs_value=0,sec_value=0;
int count=0,increment=0;

void timer0() interrupt 1
{

  EA=0;
   TH0=0x00;
   TL0=0x00;
   count++;       //everytime timer overflows count is incremented
   if(count==11)  //if count is 11 then make increment=1
    {             //why 11 because if timer overflows for 11 times  
     count=0;     //then it will be 1sec
     increment=1;
    }
 else 
  increment=0;
  TF0=0;
  EA=1;
}

Wednesday, March 7, 2012

LCD in 4bit MODE -8051



/* LCD 4bit MODE-  D7-D4 of LCD are connected to P2.7-P2.4

   ALGORITHM- first higher byte is sent and then the lower byte
          
     step1: mask the Lower nibble and send them to LCD 
               (temp= value & 0xf0);
          send(temp);
     step2: enable pulse
     step3: left shift the value for 4 times, which makes lower nibble
            moves to higher nibble and higher nibble moves to lower nibble
          temp= value<<4;
       temp=value & 0xf0;
       send(temp);
     step4: enable pulse      */


#include<reg51.h>

void delay_msec(int);
void lcd_init();
void lcd_data(char);
void send(char);
void lcd_cmd(char);
void lcd_dataS(char *p);
void lcd_data_int(int);

sbit rs=P2^0;
sbit en=P2^1;

//***********************************------
void main()
{
  P2=0x00;
  rs=en=0;
  lcd_init();
  lcd_dataS("hello pc");
  lcd_cmd(0xc0);
  lcd_data_int(555);
  while(1)
  {
  }
}

//*************************************

Thursday, March 1, 2012

Security Door project Program for 8051


#include<reg51.h>
#include"lcd_display.h"

void column1();
void column2();
void column3();
void resetPassword();
void getNewPassword();
char getkey();

sbit c1=P0^0;
sbit c2=P0^1;
sbit c3=P0^2;
sbit r1=P0^3;
sbit r2=P0^4;
sbit r3=P0^5;
sbit r4=P0^6;
sbit reset_password=P1^2;
sbit ON=P1^3;

char reset_code[3]={'9','9','9'},password[6];

int i=0,count=0,danger=0;
int col,row;
char num[4][3]={{'1','2','3'},
                {'4','5','6'},
       {'7','8','9'},
       {'*','0','#'}};

void main()
{
  char c;
  c1=c2=c2=1;
  r1=r2=r3=r4=0;
  reset_password=ON=1;
  rs=en=0;
  P2=0x00;
  TMOD=0x01;
  lcd_init();
 

Saturday, February 25, 2012

Keypad Interfacing with 8051 Program


#include<reg51.h>

void lcd_cmd(char);
void lcd_init();
void lcd_data(char);
void delay(int);

sbit rs=P2^0;
sbit oe=P2^1;

void column1();
void column2();
void column3();
char getkey();

sbit c1=P1^0;
sbit c2=P1^1;
sbit c3=P2^2;
sbit r1=P2^3;
sbit r2=P2^4;
sbit r3=P2^5;
sbit r4=P2^6;

int x,y;
char num[4][3]={{'1','2','3'},
                {'4','5','6'},
       {'7','8','9'},
       {'*','0','#'}};
void main()
{
char c;

Token System Program for 8051


#include<reg51.h>

void lcd_cmd(char);
void lcd_init();
void lcd_data(char[]);
void delay(int);
void lcd_dataint(int);

void counter1();  //to print the count value at counter1 location
void counter2();                                     //(on lcd)
void counter3();

sbit rs=P2^4;
sbit oe=P2^0;
sbit but1=P2^1;   //counter1 button 
sbit but2=P2^2;   //counter2 button
sbit but3=P2^3;   //counter3 button

int token_no=0;   //overall count 

void main()
{
   rs=0;
   oe=0;
   but1=1;but2=1;but3=1;
   TMOD=0x01;
   lcd_init();
   lcd_data("C1    C2    C3  ");

Simple ELEVATOR program for 8051



#include<reg51.h>
#include"lcd_display.h"

sbit ON = P1^0;
sbit floor1 = P1^1;
sbit floor2 = P1^2;
sbit floor3 = P1^3;
sbit dooropen = P1^4;

sbit motorF = P2^0;
sbit motorR = P2^1;
sbit motor_en = P2^3;
sbit led_doorOpen = P2^2;
sbit ON_led = P2^4;

void delay_sec(int);

short int PresentLevel = 0, RequestLevel;


void main()
{
motorF = motorR = led_doorOpen = motor_en = ON_led = rs = en = 0;
ON = floor1 = floor2 = floor3 = dooropen = 1;



TMOD = 0x01;
P3=0x00;
lcd_init();
motor_en=0;

Friday, February 24, 2012

Wired ROBO car Program for 8051

/* wired robo car program for 8051 microcontroller
 design description:;: contains two motors one on left(ml) and one on right(mr)::contains headlights and backlights::moreover this is wired robo car (not wireless) */
#include<reg51.h>

sbit mr_p = P2^0;      //motor_right_positive
sbit mr_n = P2^1;      //motor_right_negetive
sbit ml_p = P2^2;      //motor_left_positive 
sbit ml_n = P2^3;      //motor_left_negetive
sbit leds_front = P2^4;
sbit en_mr = P2^6;     //motor_right_enable
sbit en_ml = P2^7;     //motor_left_enable
sbit led_backL = P3^0;
sbit led_backR = P3^1;

sbit head_lights = P1^6;    //inputs
sbit key = P1^5;
sbit fw = P1^0;
sbit re = P1^1;
sbit left = P1^2;
sbit right = P1^3;
sbit stop = P1^4;

void main()
{
  int i;  

  fw = re = left = right = stop = head_lights = key = 1;
  mr_p = mr_n = ml_p = ml_n = leds_front = en_mr = en_ml = 0;
  led_backL = led_backR = 0;
  

Electronic Voting Machine


#include<reg51.h>


void nominee(char[],int);

void lcd_cmd(char);
void lcd_init();
void lcd_data(char[]);
void delay(int);
void lcd_dataint(int);
void results();

sbit start=P1^0;
sbit n1=P1^1;
sbit n2=P1^2;
sbit n3=P1^3;
sbit rs=P2^0;
sbit oe=P2^1;
sbit again=P1^4;
sbit result=P1^5;

int nom[3]={0,0,0};
int overallC=0,permission=0;

     
  void main()
   {
     n1=n2=n3=start=1;
     oe=rs=0;
     P3=0x00;
     TMOD=0x01;