Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

DIGITAL

TASBEEH
(2 Digit 7-Segment Up Down Counter
Project using 89C51 Microcontroller)
INTRODUCTION
A counter that can change its state in either direction, under c o n t r o l o f a n u p
d o w n s e l e c t o r i n p u t , i s k n o w n a s a n up down counter . Th e c i r c u i t
g i v e n h e r e c a n c o u n t n u mb e r s from 0 to 99 in up and down modes
depending upon the state of the selector. It can be used to count the
number of any thing in the up mode. In the down mode, it can count the number
of any things that are decreasing. In Islamic countries, mostly it is known as
TASBEEH and used for Islamic prayers. Th i s c i r c u i t d i v i d e d i n t h r e e
p a r t s : p u s h b u t t o n s , c o n t r o l l er a n d counter display. By pushing the
button interrupt is provide as input to the controller which would run the
counter in up/down mode depending upon the selector
setting. The same count is displayed on a set of 7-segment displays through
the controller.

APPRATUS
SR.NO
1
2
3

COMPONENT
AT89C51
Microcontroller
7 Segment
Display
Capacitor(33pf)

QUANTI
TY
1
2
3

Push Button

Resistor (1k)

Crystal
Oscillator(12MHz)
CIRCUIT DIAGRAM

PROTEUS DIAGRAM

3
1
1

2 DIGITS UP/DOWN COUNTER CIRCUIT WORKING


PRINCIPLE:
The main principle of this circuit is to increment the values on
seven segment displays by pressing the button. When button 1 is
pressed value on the display is incremented by one value and
when other button is pressed value on the display is decremented
by one value. The value on the display can be incremented and
decremented from 0-99 as it uses only 2 displays. If one wants to
display 3 digits, three displays should be used .There are many
circuits available for 2 digits up/down counter but using a
microcontroller reduces components and space on the board but
simple programming is required.

DESCRIPTION:
In this circuit 2 seven segment are used to show the value of
count using 8051 microcontroller. The maximum value of count is
99 because 2 seven segments are used. In this circuit we are
using 8051-microcontroller, 2 common cathodes seven segments,
2 switches for up counting button & down counting button.

7-Segments are connected to P2 & P3 ports of the 8051


microcontroller. UP counter button is connected with P1.6 and
down counter button is connected with P1.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 .

COMPONENTS USED:
AT89C51 Microcontroller:
AT89C51 is an 8-bit microcontroller and belongs to Atmel's
8051 family. ATMEL 89C51 has 4KB of Flash programmable
and erasable read only memory (PEROM) and 128 bytes of
RAM. It can be erased and program to a maximum of 1000
times

Seven Segment Display:


A seven segment display is the most basic electronic display
device that can display digits from 0-9. They find wide
application in devices that display numeric information like
digital clocks, radio, microwave ovens, electronic meters etc.
The most common configuration has an array of eight LEDs

arranged in a special pattern to display these digits. They


are laid out as a squared-off figure 8

Crystal Oscillator
A crystal oscillator is an electronic oscillator circuit that uses the
mechanical resonance of a vibrating crystal of piezoelectric
material to create an electrical signal with a precise frequency. This
frequency is commonly used to keep track of time, as in quartz
wristwatches, to provide a stable clock signal for digital integrated
circuits, and to stabilize frequencies for radio
transmitters and receivers. The most common type of piezoelectric
resonator used is the quartz crystal, so oscillator circuits incorporating
them became known as crystal oscillators,[1] but other piezoelectric
materials including polycrystalline ceramics are used in similar
circuits.
Quartz crystals are manufactured for frequencies from a few tens
of kilohertz to hundreds of megahertz. More than two billion crystals
are manufactured annually. Most are used for consumer devices such
as wristwatches, clocks, radios, computers, and cellphones. Quartz

crystals are also found inside test and measurement equipment, such
as counters, signal generators, and oscilloscope

push-button
A push-button (also spelled pushbutton) or simply button is a
simple switch mechanism for controlling some aspect of a machine or
a process. Buttons are typically made out of hard material,
usually plastic or metal. The surface is usually flat or shaped to
accommodate the human finger or hand, so as to be easily
depressed or pushed. Buttons are most often biased switches,
though even many un-biased buttons (due to their physical nature)
require a spring to return to their un-pushed state. Different people
use different terms for the "pushing" of the button, such
as press, depress, mash, hit, and punch.

CODE
#include< reg51.h >
sbit h=P1^6; //up counter button
sbit g=P1^7; //down counter button
int m=0;
int n=0;
int a,b;
int
arr[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0xFF,0x67
};
void main()
{
P2=0x3F;
P3=0x3F;
while(1)
{
P1=0xFF;
if(h==0)
{
if(n==99&&m==99)
{
P2=0x67;
P3=0x67;
}
else
{
m=m+1;
n=n+1;
a=m/10;
b=n%10;
P2=arr[a];
P3=arr[b];
while(h==0);
}
}
if(g==0)
{
if(n==0&&m==0)

{
P2=0x3F;
P3=0x3F;
}
else
{
m=m-1;
n=n-1;
a=m/10;
b=n%10;
P2=arr[a];
P3=arr[b];
while(g==0);
}
}
}
}

You might also like