Lab 1 - Digital Input-Output Interfacing and Programming
Lab 1 - Digital Input-Output Interfacing and Programming
Experiment # 1
Digital Input/Output Interfacing and
Programming
Objective
• To configure & use the GPIO pins of PIC microcontroller
• To develop a C program, to control an LED and 7-segment display using GPIO pins of PIC
microcontroller
• To simulate the whole scenario in Proteus Software for code verification
Introduction to GPIO
A microcontroller communicates with the outside world either by setting the voltage on the pin high (usually
3.3/5V) or low (usually 0V) or reading the voltage level of an input pin as being high (1) or low (0). We
refer to these pins as general purpose input output (GPIO) pins. Any GPIO pin can be configured through
software to be either a digital input or a digital output. GPIO outputs let you translate logical values within
your program to voltage values on output pins and voltage outputs help your microcontroller exert control
over the system in which it is embedded.
Task#1
Interface a single LED with PIC microcontroller
a) Write a C program to blink an LED with a time interval of 0.5 seconds continuously
b) Simulate the circuit on Proteus and verify your program.
Refer to this [link] , to understand the associated concepts.
Simulation (Proteus):
A seven-segment display consists of seven LEDs arranged in the form of a squarish ‘8’ slightly inclined to
the right and a single LED as the dot character. Different characters can be displayed by selectively glowing
the required LED segments. Seven segment displays are of two types, common cathode, and common
anode. In common cathode type, the cathodes of all LEDs are tied together to a single terminal which is
usually labeled as ‘com’ and the anode of all LEDs are left alone as individual pins labeled as a, b, c, d, e, f,
g & dot. In common anode type, the anodes of all LEDs are tied together as a single terminal and cathodes
are left alone as individual pins. Both the configurations are shown in Figure.
Task#3
Interface 7-segment display with PIC microcontroller
a) Write a C program to display the all the digits from 0-9 and all those alphabets of your name that
are in the range of A-F, with a time interval of 0.3 seconds continuously. [link]
b) Simulate the circuit on Proteus and verify your program.
c) Repeat the above two steps for the following:
a. Interface the four 7-segment display units and display the first four alphabets of your name.
Use the concept of multiplexing to save the number of pins of your microcontroller.