Вы находитесь на странице: 1из 6

Here we have used PIC 16F877A micro controller to light up this display system.

There
were several reasons to choose this microcontroller for out product.
1. PIC 16F877A microcontroller can be easily found from the local market.
2. Ease of programming using high level language.
3. Low cost microcontroller.
4. Ease of mounting due to the available dual inline package.

Following is a brief description about the PIC16F877A microcontroller and the


programming aspects that we have used.

PIC16F877A is a microcontroller that is made by Microchip company. This is a


medium level micro controller which comes with number of peripherals which are
required for typical applications such as Analog to digital controllers, Serial
communication interface (USART) etc.

In our project both PORTA PORTB PORTC and PORTD are used to input output
purposes. PORTB is used to give the inputs to the microcontroller and the other three
Ports are used to take the output signals to lightup the LED s according to the
required pattern. Nine push button switches are connected to the PORT B and
PORTC to take the inputs from the user. And also PORTA is used to control the
biasing of a set of transistors for better sitching purpose. PORTC and PORTD are
directily connected to a LED metrix to light up required LEDs according to the input
signal given by the user..
Programming aspects

start This is the main control algorithm that we have use in our design.
Program takes input signals from the user and call relevant functions
to light up the correct paths in the display system
Initialize
the PIC

Read PORTB

NO
Is RB0=0?

YES NO
Is RB1=0?

Call
Badminto NO
n() YES Is RB2=0?

Call
Carrom() YES NO
Is RB3=0?

Call
Tennis()
YES NO
Is RB4=0?

Call
Tab_Ten
nis() YES
NO
Is RB5=0?

Call
ground()
YES NO
Is RB6=0?

Call
vollyball( NO
) YES
Is RB7=0?

Call
Baskt_bal
l() YES NO
Is RC0=0?

Call Call
gym() Net_ball(
YES )
MikroC programming language is used for the programming purpose of this
microcontroller. We could use simple C program codes to implement our program
task as a result of using this IDE.

The Source code implemented in mikroC

int i;
void initialize(){
TRISA=0; // Port A outputs for transisors
PORTA=0;

TRISB=0xFF; // PortB inputts for 8 switches


PORTB=0;

TRISC=0; // PORT C and D are outsputs for LED paths


PORTC=0;

TRISD=0;
PORTD=0;

void badminton(){
PORTA= 0b00000001;
for(i=0; i<5;++i){
PORTC=0b00000001;
delay_us(500);
PORTC=0b00000010;
delay_us(500);
PORTC=0b00000100;
delay_us(500);
PORTC=0b00001000;
delay_us(500);
PORTC=0b00010000;
delay_us(500);
}
PORTC=0b00000000;

void carrom(){

void netball(){

void basketball(){

void vollyball(){

void tennis(){

void tab_tannis(){

void play_ground(){

void gym(){

}
void main(){

initialize(); // initialize the PIC ports


while(1){

if(PORTB.F0==1 && PORTB.F1==0 && PORTB.F2==0 && PORTB.F3==0 &&


PORTB.F4==0 && PORTB.F5==0 && PORTB.F6==0 && PORTB.F7==0 ){
// swich 1 has been pressed

badminton(); // Show the path 1

}else if(PORTB.F0==0 && PORTB.F1==1 && PORTB.F2==0 && PORTB.F3==0


&& PORTB.F4==0 && PORTB.F5==0 && PORTB.F6==0 && PORTB.F7==0){

carrom();

}else if(PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==1 && PORTB.F0==0


&& PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0) {

netball() ;

}else if(PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==1


&& PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0){
basketball();

}else if(PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0


&& PORTB.F0==1 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0){
vollyball();

}else if(PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0


&& PORTB.F0==0 && PORTB.F0==1 && PORTB.F0==0 && PORTB.F0==0){

tennis();

}else if(PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0


&& PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==1 && PORTB.F0==0){
tab_tannis();
}else if(PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0
&& PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==0 && PORTB.F0==1){
play_ground();

}
}
}

The function of the program

When the PIC MPU got powered, it is entered to a infinite loop which reads the
PORTB values. The values of PORTB remain in 0 values until a button is pressed. As
soon as a button is pressed, a high voltage (+5V) is generated at the relevant pin .so
that the MPU can identify which button is pressed by the user. Then it calls a
relevant function according to the pressed button. There are nine functions named as
badminton, tennis, tab_tannis, playground, netball, volleyball, basketball. Each
represents a path to each sport. All the codes need to light up the required path are
written inside those functions.

Вам также может понравиться