0% found this document useful (0 votes)
157 views

Project 2 Digit Up/Down Counter Circuit Using Microcontroller 8051

This document describes a 2-digit up/down counter circuit using an 8051 microcontroller and two 7-segment displays. The circuit uses buttons to increment or decrement the displayed value from 00 to 99. The microcontroller reads the button states and updates the 7-segment displays accordingly using a code algorithm. Programming the microcontroller simplifies the circuit design compared to other solutions. Potential applications of this counter circuit include scoreboards and counting objects or people.

Uploaded by

Desi Marne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views

Project 2 Digit Up/Down Counter Circuit Using Microcontroller 8051

This document describes a 2-digit up/down counter circuit using an 8051 microcontroller and two 7-segment displays. The circuit uses buttons to increment or decrement the displayed value from 00 to 99. The microcontroller reads the button states and updates the 7-segment displays accordingly using a code algorithm. Programming the microcontroller simplifies the circuit design compared to other solutions. Potential applications of this counter circuit include scoreboards and counting objects or people.

Uploaded by

Desi Marne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Project

2 Digit Up/Down Counter


Circuit Using
Microcontroller 8051

Submitted By:

Name : Vipul Landge Roll no: 42 Class : SY BCS

Name : Hirutvik Lingayat Roll no: 43 Class: SY BCS


Introduction:

Generally, you can see the digital displays which display


the score when buttons are pressed on score boards. The
main heart of this score board is 2 digits up down counter
circuit. The 2 digits are displayed on two 7 segment
displays.

2 Digit Up Down Counter Circuit Principle:

Main principle of the 2 Digit Up Down Counter circuit is to


increment the values on seven segment displays by
pressing the button. When button 1 is pressed, the value
on the display is incremented by one and when the other
button is pressed, the value on the display is decremented
by one.

The value on the display can be incremented and


decremented from 0-99 as it uses only 2 displays. If you
want to display 3 digits, three displays should be used i.e.
three 7-Segment Displays. There are many circuits
available for 2 digit up/down counter but using a
microcontroller reduces components and space on the
board but simple programming is required
Two Digit Up Down Counter Circuit Diagram

Using 8051 Microcontroller


Circuit Design of 2 Digit 7-Segment Up Down Counter

There are mainly two types of seven segment displays 1)


common cathode 2) common anode. The display here
used is common cathode display. Generally for common
cathode displays, common pin should be grounded and for
common anode, it should be connected to VCC.

In Seven segment display, there are seven segments and


they are similar to seven LEDs. Seven pins belong to
these seven segments where as the last pin is dot at the
coner of the display. For common cathode, display
assigning logic1 to the segment pin glows particular
segment. In case of common anode, the segment pin
should be assigned logic0 in order to glow the segment.
Each segment is given one name starting from ‘a ‘and last
segment dot is ‘h’.

In our circuit, seven segment display is connected to micro


controller through a current limiting resistor of 330 ohms.
Two buttons in pull- down mode are also connected.

The necessity of connecting the buttons in pull down mode


is to avoid floating state of the button i.e. unknown state. If
the button is connected in pull down mode, this ensures
that button is initially in logic0 state.
How to Operate 2 Digit Up Down Counter Circuit?

1. Initially, power the circuit.


2. The values displaying on seven segments is ‘00’.
3. Press the button 1 in the circuit. The value on the
seven segments is incremented to ‘01’.
4. Again press button 1. Value on the displays is ’02’.
5. Now, press the second button. You can see the value
decrementing to 01.
6. The value on the displays can be incremented up to
99, after 99 if button 1 is pressed it starts
incrementing from ‘01’. If the second button is
pressed after decrementing to ‘00’, it displays ‘00’.
This value can be changed only after incrementing
the value atleast to ‘01’.
Algorithm for Programming

1. Declare the corresponding PORTS of the


microcontrollers as input or output.
2. Declare an array with the seven segment codes i.e, if
number one is to be displayed, then the binary value
that should be passed is as follows:

dp g f e d c b a

1 1 1 1 1 0 0 1

This is because b and c segments should be assigned


with logic 0 to display ‘1’, I am using a Common Anode
7-Segment Display . So, the binary value 0b11111001 or
the hexadecimal value 0xf9 is assigned to the particular
port on which ‘1’ is to be displayed. The array should
consist of 0-9 binary or hexa values.

3. Check the status of the buttons using if else loop.


4. If the button 1 is pressed for first time, first seven
segment (on the left) should display 0 and the other
should display 1. So the output is ‘01’.
5. If the button 1 is pressed for second time, value on
second button should be incremented by one.
6. If the second button is pressed, value on the first
segment should be decremented by one value.
#include<reg51.h>
#define SEGMENT P0
sbit switch1=P3^0;
sbit switch2=P3^1;
sbit digit1=P2^0;
sbit digit2=P2^1;
void delay (int);
int x=0,y,z;
unsigned char
ch[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x9
8};
void delay (int d)
{
unsigned char i;
for(;d>0;d--)
{
for(i=250;i>0;i--);
for(i=248;i>0;i--);
}
}
void main()
{
switch1=1;
switch2=1;
digit1=1;
digit2=1;

while(1)
{
if(switch1==0)
{
x++;
delay(200);
}
else if(switch2==0)
{
x--;
delay(200);
}
y=x/10;
SEGMENT=ch[y];
digit1=0;
delay(10);
digit1=1;
z=x%10;
SEGMENT=ch[z];
digit2=0;
delay(10);
digit2=1;
}
}
2 Digit Up Down Counter Circuit Applications

1. This circuit can be used in scoreboards.


2. Up/down counter is used for counting number of
objects passed through a point.
3. It is used to count number of persons entering a
room.

Limitations of this Circuit

This particular Up/Down Counter circuit is limited to 2


digits i.e. 0-99. If more than 3 digits are required, one
should use another display which requires more pins from
the controller.

Conclusion:

In this way, we have designed 2 digit up down counter


using microcontroller 8051.

You might also like