Showing posts with label Embedded C. Show all posts
Showing posts with label Embedded C. Show all posts

Saturday, March 3, 2012

Calculator Project with just keypad and LCD 8051

/* calculator Project for 8051---
   Possible Operation- add, sub, mul, div
   limitations- decimal part is truncated
                result upto only 6decimals */
/* algorithm::
     step1:store the entered values in an array
         if any operator key is pressed goto step2
  step2:store the var1 here (using convertArrayToDecimal() function)
        and also store the operator pressed
         if '=' operator is pressed goto step3
  step3:do the respective operation and display the result */
#include<reg51.h>
#include"lcd_display.h"

int pow(int, int);
void convertArrayToDecimal(int*);
void clear_array();
void column1();
void column2();
void column3();
void column4();
char getkey();

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


int var1=0,var2=0,dummy_var,row,col;

char values[4][4]={{55,56,57,'/'},
                   {52,53,54,'*'},
          {49,50,51,'-'},
          {' ',48,'=','+'}};

int num[5]; // to store the entered keys
int i=0;
void main()
{
char key;
unsigned char operation;
int var_count=0;
int result;

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;