/* 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; }
Thursday, March 8, 2012
Time Display On LCD using 8051 Microcontroller
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) { } } //*************************************
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();
Subscribe to:
Posts (Atom)