Up-Down counter on 16*2 LCD using 8051 microcontroller

CIRCUIT DIAGRAM

DESCRIPTION

In this circuit 16*2 lcd IS used to show the value of count using 8051 microcontroller. The maximum value of count is 99 because. In this circuit we are using 8051-microcontroller, 16*2 lcd, 2 switches for up counting button & down counting button.

Data pins of LCD are connected to P1 port of the 8051 microcontroller. UP counter button is connected with P2.6 and down counter button is connected with P2.7.Whenever the UP counter button is pressed the counter increments by one and when the down counter button is pressed it gets reduced by one.

PROJECT CODE

#include< reg51.h >

sfr lcddata=0x90; //LCD DATA PINS
sbit rs=P3^2;
sbit rw=P3^3;
sbit en=P3^4;
sbit g=P2^6;
sbit h=P2^7;

int m=0;
int a,b;
unsigned char n[10]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};

void delay(unsigned char b)
{
unsigned char a;
for(b;b>0;b–)
{
for(a=500;a>0;a–);
}
}

void command(unsigned char dost)
{
lcddata=dost;
en=1;
rs=0;
rw=0;
delay(5);
en=0;
}

void lcddisplaydata(unsigned char n)
{
lcddata=n;
en=1;
rs=1;
rw=0;
delay(50);
en=0;
}

void main()
{
P2=0xFF;
command(0x38);
command(0x0C);
while(1)
{
if(g==0)
{
if(m==99)
{
command(0x80);
lcddisplaydata(n[9]);
command(0x81);
lcddisplaydata(n[9]);
}
else
{
m=m+1;
a=m/10;
{
command(0x80);
lcddisplaydata(n[a]);
}
b=m%10;
{
command(0x81);
lcddisplaydata(n[b]);
}
while(g==0);
}
}

if(h==0)
{
if(m==0)
{
command(0x80);
lcddisplaydata(n[0]);
command(0x81);
lcddisplaydata(n[0]);
}
else
{
m=m-1;
a=m/10;
{
command(0x80);
lcddisplaydata(n[a]);
}
b=m%10;
{
command(0x81);
lcddisplaydata(n[b]);
}
while(h==0);
}
}
}
}

Advertisements

3 thoughts on “Up-Down counter on 16*2 LCD using 8051 microcontroller

  1. Thanks for your publication. What I want to comment on is that when searching for a good online electronics go shopping, look for a website with entire information on critical factors such as the privacy statement, safety measures details, payment procedures, and other terms in addition to policies. Often take time to see the help and FAQ areas to get a much better idea of what sort of shop performs, what they are capable of doing for you, and exactly how you can make best use of the features.

  2. Having read this I believed it was extremely enlightening. I appreciate you spending some time and effort to put this short article together. I once again find myself spending a significant amount of time both reading and leaving comments. But so what, it was still worthwhile!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s