Design of PIC test Board

Updated on 2017/11/15 12:04


Design a PIC 18Fxxxx  test board to test the LED, Buzzer and Relay connected to ports and control them using keys or switches

Note : While designing the PIC test Board  look into the problem carefully and start working accordingly, program is mandatory

Answer: Following fig. shows the design of PIC test board for verifying the LED connected to port B, with switches and Buzzer to port D, with relay interface for Port A.

Step1: Design of Power Supply:

The microcontroller selected is PIC 18F4550 which works on the frequency of oscillator ranging from 0 to 20 MHz and requires power supply of ± 5 or ±12 V. A simple circuit design for +5 V is shown in Fig. 


Fig. Design of  +5V Power Supply 

Step2: Design of Clock Circuit:

The Quartz crystal is connected to OSC1 and OSC2 pin in order to synchronize the operation of all components connected with internal and external means. The values for C1 and C2 are selected according to the crystal frequency for stabilizing the oscillator pulses. In general with quartz crystal 22-33 µF is preferred.

Step3: Design of Reset Circuit:

The RC high pass filter with C=0.1µF along with 20 kΩ register is connected to MCLR pin. When high pulse appear on it, resets the contents of inter registers and SFRS to initial value.

Step4: Configuration of Port

PIC has 33 I/O lines which can be configured as input and output using TRISX register as

  • If TRISX = 0 —Ports (A-E) are configured as output ports 
  • If TRISX = 1 —Ports (A-E) are configured as input ports.

Step 5: Connection Diagram:


Fig.Minimum connection Diagram PIC Test board

Step 6 : Algorithm

Step 1 : Initialize TRIS SFR for direction control
Step 2 :Check status of switch
Step 3 : If closed, load bit pattern to glow LED, switch on buzzer and energizes the relay.

Step 4 :Otherwise wait till closer
Step 5 :Transfer content to Port register
Step 6 :Wait for some time i.e. delay
Step 7 :Load same or different data sequence of LED glowing
Step 8 :Continue Go to step 2 

Step 7: Embedded C Program

void delay(void);
void main()
unsigned char i, key;
TRISB = 0x00;//Configure PORTB pins as an output
LATB = 0x00;
TRISDbits.TRISD0 = 1;//set RD0 as input
TRISDbits.TRISD1 = 1;//set RD1 as input
TRISDbits.TRISD2 = 0;//set buzzer pin RD2 as output
TRISAbits.TRISA4 = 0;//set relay pin RA4 as output
LATDbits.LD0 = 1;
LATDbits.LD1 = 1;
if(PORTDbits.RD0 == 0)
key =0;
if(PORTDbits.RD1 == 0)
key =1;
if(key == 0)
LATAbits.LATA4 = 1;
LATDbits.LATD2 = 0;
LATB = 0X01<<i;
LATB = 0x00;
if(key == 1)
LATAbits.LATA4 = 0;
LATDbits.LATD2 = 1;
LATB = 0X80>>i;
LATB = 0x00;
void delay()
unsigned int j,k;


  • Created, Edited, and Notes by Dr. D. S. Mantri, Sinhgad's SIT, Lonavala, Pune
  • WikiNote Foundation
Created by Sujit Wagh on 2017/11/13 12:48