You are currently viewing How to Interface Digital-Inputs with PIC16F – PIC Advanced Development Board

How to Interface Digital-Inputs with PIC16F – PIC Advanced Development Board

Spread the love

PIC16F/18F Advanced Development Board this is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students.

The kit supports in system programming (ISP) which is done through USB port Microchip’s PIC (PIC16F877A)PIC16F/18F Slicker Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 8-bit Microcontrollers.


A switch is an electrical component that can break an electrical circuit.Which means interrupting the current or diverting it from one conductor to another. A switch may be directly manipulated by a human as a control signal to a system, or to control power flow in a circuit.

Interfacing Digital-Inputs

Fig. 1 shows how to interface the switch to microcontroller. A simple switch has an open state and closed state. However, a microcontroller needs to see a definite high or low voltage level at a digital input. A switch requires a pull-up or pull-down resistor to produce a definite high or low voltage when it is open or closed. A resistor placed between a digital input and the supply voltage is called a “pull-up” resistor. Because it normally pulls the pin’s voltage up to the supply.

Fig. 1 Interfacing Digital-Inputs

Fig. 1 Interfacing Digital-Inputs

Interfacing digital-Inputs with PIC16F877A

We now want to control the LED by using switches (Digital-Inputs) in PIC16F/18F Slicker Board. It works by turning ON a LED. Then turning it OFF when switch is going to LOW or HIGH.The PIC16F/18F Slicker Board has eight numbers of point LEDs. Those LEDs connected with I/O Port lines (PORTB.0 – PORTB.7) to make port pins high. Eight switches, connected with I/O port lines PORTC are used to control eight LEDs.

Pin Assignment with PIC16F877A

Circuit Diagram to Interface Switch with PIC16F877A

Source Code

The Interfacing switch with PIC16F877A program is very simple and straight forward. That can control leds by using switches when it going LOW or HIGH.

C Program to switch functions using PIC16F

// Define PIC Registers __CONFIG(0x3f72);
//Select HS oscillator, Enable (PWRTE,BOREN),
//Disable (CPD,CP,WDTEN,In-circuit Debugger) void DelayMs(unsigned int);
void main()
// Enable weak internal Pull-Ups TRISB=0xFF;
// PORTB Configured as I/P TRISC=0x00;
// PORTC configured as O/P PORTC=0x00; DelayMs(10);
// Move the input to output DelayMs(500);
void DelayMs(unsigned int Ms)
int delay_cnst; while(Ms>0)
for(delay_cnst = 0;delay_cnst <220;delay_cnst++);

To compile the above C code you need the Mplab software & Hi-Tech Compiler. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Mplab, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without PIC16F/18F Slicker Board.The PICKIT2 software is used to download the hex file into your microcontroller IC PIC16F877A through USB port.

Testing the Digital-Inputs with PIC16F877A

Give +12V power supply to PIC16F/18F Slicker Board . The switches are connected with the PIC16F/18F Advanced Development Board .After that,Check the LED’s & switches are working or not.If you are not reading any output signal in LED, then you just check the jumper connections. Otherwise you just check the code with debugging mode in Mplab.If you want to see more details about debugging just see the videos in below link.

General Information

  • For proper working use the components of exact values as shown in Circuit file. Wherever possible use new components.
  • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
  • Use the exact value crystal shown in schematic.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.