Workshop 4: Digital Electronics & Microcontroller
Workshop 4: Digital Electronics & Microcontroller
Workshop 4
Title:
PIC interactive input/output
Objectives:
Learn to write a program for up/down 7-segment LED display by detecting different
button input.
Apparatus:
mikroC compiler for PIC, PIC programmer (Top2005 universal programmer)
Components:
PIC 16F627 and PIC test board
Procedures
1.
/*0*/
/*1*/
/*2*/
/*3*/
/*4*/
/*5*/
/*6*/
/*7*/
/*8*/
/*9*/
store the current display digit */
PORTB = seg7[0];
TRISB = 0;
CMCON = 0x07;
/* enable digital I/O for PORTA */
TRISA.F0 = 1;
TRISA.F1 = 1;
while (1) {
if (PORTA.F0 == 0)
/* when RA0 is pressed */
{
index = index + 1;
if (index == 10)
index = 0;
PORTB = seg7[index];
Delay_ms(1000);
}
}
}
2.
Set all jumpers to drive 7-segment LED. When received input from "Up" button
connected to RA0, the 7-segment LED will change from "0" to "1" and so on until "9"
and then back to "0". Demo it to the lab supervisor.
Sign: __________________
Workshop 4
3.
Modify the above program. When received input from "Down" button connected to
RA1, the 7-segment LED will change from "9" to "8" and so on until "0" and then back
to "9". Demo it to the lab supervisor.
Sign: __________________
4.
Advance programming:
Combine the above programs to accept inputs from Up and Down buttons. Demo it
to the lab supervisor.
Sign: __________________